Skip to content

fields iterators causes incorrect lineinfo placement on cannot evaluate at compile time errors #1617

@Luyten-Orion

Description

@Luyten-Orion

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.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/semRelated to semantic-analysis system of the compilergood first issueEasy-to-start-with issue requiring no in-depth knowledge or complex implementation.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions