Repository navigation
Fix untraced IM element traces, doubled exception header, UnionFind rank - #1474
Merged
Merged
Conversation
getTrace(Element) searched with `while (q.isEmpty())`, so the loop never ran and every IM element without a trace of its own reported Ast.NoExpr(). Anything made from such an element lost its source position: with -stacktraces on Lua, a concatenation lowered to __wurst_stringConcat printed "when calling __wurst_stringConcat" without file and line. Walk the parents instead. The search it replaces also queued children, which would have revisited nodes forever and could pick a sibling's trace that does not contain the element.
printExceptionWithStackTrace already starts with the exception itself, so prepending it again printed the first line twice in the "Encountered compiler bug" diagnostic.
Union by rank put the rank back unchanged, so every root kept rank 0 and the second argument's tree always went below the first. Only the shape of the trees changes: LuaDispatchPreparation groups by the root and orders the groups by its own method order, so Lua output is unchanged.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Three small latent bugs, one commit each, each with a repro that fails before the fix.
ImAttributes.getTrace(Element): the search ranwhile (q.isEmpty()), so it never looped and every IM element without its own trace reportedAst.NoExpr(). Anything built from such an element lost its source position. Visible case: with-stacktraceson Lua, a concatenation lowered to__wurst_stringConcatprinted"when calling __wurst_stringConcat"with no file or line. It now prints e.g."... in Colors, line 217"like every other call. The fix walks the parents to the nearest traced ancestor (the behaviour before 2019). The breadth-first search it replaces also queued children, so simply flipping the condition would have revisited nodes forever. It could also pick a sibling's trace, one that does not contain the element. Detached untraced elements still getNoExpr.Utils.printException:printExceptionWithStackTracealready starts with the exception, so the "Encountered compiler bug" diagnostic printed the first line twice.UnionFind.union: union by rank put the rank back unchanged, so every root stayed at rank 0. Only the tree shape changes.LuaDispatchPreparationgroups by root and orders groups by its own method order, so Lua output is unchanged.Tests:
ImTraceTests(new),UnionFindTests(new),UtilsTest, andLuaTranslationTests.aLoweredConcatenationKeepsItsPositionInAStackTrace(new).Output check: I compared
test-outputbefore and after overDeterministicChecks,LuaBackendAuditTests,OptimizerTests,LuaTranslationTestsandBugTests: 1574 emitted files, all byte-identical except threeLuaTranslationTestsLua files. Their only change is the stack-trace position string above. Only Windows was run locally.