fix: Molang rewrite of math constants to avoid function conversion#487
Merged
Conversation
DaanV2
approved these changes
May 13, 2026
…ng optimizations - In `string.ts`: Don't append `()` for zero-argument FunctionCall nodes (e.g. `math.pi`) so that constants are serialized correctly without parentheses. - In `nodes.ts`: Fix infinite loop in `getLastEndPosition` for FunctionCall with 0 args by returning early with the correct identifier length. - In `nodes.ts`: Add `ExpressionNode.getStartPosition()` helper that finds the minimum (leftmost) source offset among all descendants of an expression node. - In `registry.ts`: Use `OffsetWord` with the full expression range (from `getStartPosition` to `getLastEndPosition`) when adding optimization diagnostics, so code actions replace the correct text instead of just the operator and adjacent identifier. - In `optimizations.test.ts`: Add regression test asserting that `5*3*math.pi` produces a replacement containing `math.pi` and not `math.pi()`. Agent-Logs-Url: https://github.com/Blockception/minecraft-bedrock-language-server/sessions/c46da7a3-c138-4dfb-a355-ca41b9f597bc Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>
9480ca5 to
3b9ddc2
Compare
DaanV2
approved these changes
May 15, 2026
Contributor
|
@copilot I have no idea where, but some or a test is hanging / not timing out in the pipelines, can you fix that and then rebase it? |
Copilot stopped work on behalf of
DaanV2 due to an error
May 15, 2026 12:14
Copilot stopped work on behalf of
DaanV2 due to an error
May 15, 2026 12:47
…on unknown node types Agent-Logs-Url: https://github.com/Blockception/minecraft-bedrock-language-server/sessions/a960ae57-46b9-48b9-a04c-2f367da71439 Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
packages/bedrock-diagnoserandide/*hang during testsforceExit: truetopackages/bedrock-diagnoser/jest.config.tsforceExit: trueto rootjest.config.ts(used by allide/*packages)getLastEndPositioninpackages/molanghas awhileloop with nodefault:case — when it encounters a node with an unknowntype(e.g. the empty{}operand produced by parsing!!v.temp), the loop spins forever since{}is neverundefineddefault: return (node as ExpressionNode)?.position ?? 0;to the switch ingetLastEndPositionpackages/molang— all 649 tests passpackages/*suites pass;ide/*finish within 60s (pre-existing 4-suite failure unrelated to this fix)