Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/lookups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ proc errorUndeclaredIdentifier*(c: PContext; info: TLineInfo; name: string, extr
err.add "; if declared in a template, this identifier may be inconsistently marked inject or gensym"
if extra.len != 0:
err.add extra
# Show import chain for better error messages
if c.graph.importStack.len > 1:
err.add "\nimported from "
for i in 0..<c.graph.importStack.len-1:
if i > 0: err.add "\n which imports "
err.add toFilename(c.config, c.graph.importStack[i])
err.add "\n at " & toFilename(c.config, info) & "(" & $info.line & ", " & $info.col & ")"
if c.recursiveDep.len > 0:
err.add "\nThis might be caused by a recursive module dependency:\n"
err.add c.recursiveDep
Expand Down
8 changes: 6 additions & 2 deletions compiler/sempass2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,12 @@ proc checkRaisesSpec(g: ModuleGraph; emitWarnings: bool; spec, real: PNode, msg:
while rr.kind in {nkStmtList, nkStmtListExpr} and rr.len > 0: rr = rr.lastSon
for (s, info) in unknownRaises.items:
message(g.config, info, hintUnknownRaises, s.name.s)
message(g.config, r.info, if emitWarnings: warnEffect else: errGenerated,
renderTree(rr) & " " & msg & typeToString(r.typ))
var effectMsg = renderTree(rr) & " " & msg & typeToString(r.typ)
# Show effect origin location for forbids violations
if isForbids and r.info != spec.info:
effectMsg.add "\n effect origin: " & toFilename(g.config, r.info) &
"(" & $r.info.line & ", " & $r.info.col & ")"
message(g.config, r.info, if emitWarnings: warnEffect else: errGenerated, effectMsg)
popInfoContext(g.config)
# hint about unnecessarily listed exception types:
if hints:
Expand Down
Loading