Repository navigation
An error in code the compiler makes is reported at the code it was made for - #581
Merged
Merged
Conversation
…de for
A node the compiler builds (a for...of's or for...in's loop, the call of
`[Symbol.iterator]`, a `using`'s dispose call) has no position, so an
error in it was reported at 1:1:
for (const x of 5) {} // 1:1: Can't resolve property 'length' of type s32
using x = 5; // 1:1: Can't resolve property 'dispose' of type s32
Each statement now records where it is (without the debug scope), and
loc() gives a node with no position that location, in the current scope;
a statement the compiler made keeps the anchor of the one it was made
for. The dispose call, made at the scope's exit, is anchored at its
declaration. #541 and #557 had stamped positions on the generated cast
and constructor nodes one at a time; this covers the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto synthesized-node-location # Conflicts: # tslang/test/tester/CMakeLists.txt
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.
Nodes the compiler builds with
NodeFactoryhave no position, so an error inside one was reported at 1:1 of the file:Found for
for...of,for...in,for await,yield*, a class[Symbol.iterator],usingandawait using. #541 and #557 fixed the generated cast, field initializers and the implicit constructor one site at a time (stampingpos). This fixes the rest in one place:mlirGen(Statement)records where the statement is, as a location without the debug scope (generatedNodesAnchor). A statement the compiler made itself (no position) keeps the anchor of the one it was made for.loc()gives a node with no position (isTextRangeEmpty()) that anchor, fused with the currentoverwriteLocand debug scope. Nodes with a position are unchanged.mlirGenDisposeOneanchors it at theusingdeclaration.The anchor holds no debug scope, so a node is never given a scope from another function:
--diJIT and--di --emit=objof loops,usingandyield*were checked.Tests:
diagnostic-location/for_of.ts,for_in.ts,using.ts, error text with line and column, failing on any:1:position. The existing threediagnostic-locationtests still pass.Full Release suite: 4092/4092 passed.
🤖 Generated with Claude Code