Skip to content

Commit

Permalink
Merge branch 'devel' into rockcavera-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
rockcavera authored Dec 27, 2022
2 parents f03ed8e + 5684093 commit c24590e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/semfold.nim
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ proc foldDefine(m, s: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
else: result = copyTree(s.astdef) # unreachable
else:
result = copyTree(s.astdef)
if result != nil:
result.info = n.info

proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode =
result = nil
Expand All @@ -593,6 +595,8 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
result = foldDefine(m, s, n, idgen, g)
else:
result = copyTree(s.astdef)
if result != nil:
result.info = n.info
of skProc, skFunc, skMethod:
result = n
of skParam:
Expand Down
7 changes: 7 additions & 0 deletions tests/errmsgs/tconstinfo.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://forum.nim-lang.org/t/9762

const foo = "abc"
case 'a'
of foo: echo "should error" #[tt.Error
^ type mismatch: got <string> but expected 'char']#
else: discard

0 comments on commit c24590e

Please sign in to comment.