Skip to content

fix #25978: show call chain for forbids violations - #26005

Open
nimamasl114514 wants to merge 1 commit into
nim-lang:develfrom
nimamasl114514:fix-25978
Open

fix #25978: show call chain for forbids violations#26005
nimamasl114514 wants to merge 1 commit into
nim-lang:develfrom
nimamasl114514:fix-25978

Conversation

@nimamasl114514

Copy link
Copy Markdown
Contributor

.forbids violations previously reported only the immediate call site with a misleading "template/generic instantiation from here" message, giving no indication of where the forbidden effect actually originates.

This PR:

  • Replaces pushInfoContext (which produced the misleading template/generic message) with a direct ".forbids spec declared here" hint
  • Adds traceForbidsOrigin which walks the callee's effect list to trace the effect back through the call graph, emitting a hint at each hop

Before:

test.nim(11, 25) template/generic instantiation from here
test.nim(12, 4) Error: c() has an illegal effect: NestedPoll

After:

test.nim(11, 25) Hint: .forbids spec declared here
test.nim(9, 14)  Hint: effect propagated from here
test.nim(8, 14)  Hint: effect propagated from here
test.nim(7, 17)  Hint: effect propagated from here
test.nim(4, 23)  Hint: effect propagated from here
test.nim(12, 4)  Error: c() has an illegal effect: NestedPoll

The raises path is unchanged — only isForbids takes the new code path.

Replaces misleading 'template/generic instantiation from here' with
'.forbids spec declared here' and traces the effect through the call
graph to show where it originates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant