nim-works/nimskull
fields iterators causes incorrect lineinfo placement on `cannot evaluate at compile time` errors
開放
#1,617 建立於 2025年9月16日
bugcompiler/semgood first issue
倉庫指標
- 星標
- (346 顆星)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
The error reported for when a variable is being accessed at compile-time in a fields iterator, uses the line info of the loop rather than the erroneous statement.
Example
type
Test = object
a: int
var test = Test(a: 1)
for v in test.fields:
when v == 2: discard
Actual Output
/home/chronos/test/main.nim(7, 10) Error: cannot evaluate at compile time: test
Expected Output
/home/chronos/test/main.nim(8, 7) Error: cannot evaluate at compile time: test
Possible Solution
Additional Information
Seems to be an issue of the lineinfo not being set correctly, since the information is attached to the for loop rather than the statement.