Skip to content
Merged
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
2 changes: 1 addition & 1 deletion compiler/semobjconstr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ proc semConstructFields(c: PContext, n: PNode, constrCtx: var ObjConstrContext,
let prevFields = fieldsPresentInBranch(selectedBranch)
let currentFields = fieldsPresentInBranch(i)
localError(c.config, constrCtx.initExpr.info,
("The fields '$1' and '$2' cannot be initialized together, " &
("The fields $1 and $2 cannot be initialized together, " &
"because they are from conflicting branches in the case object.") %
[prevFields, currentFields])
result.status = initConflict
Expand Down
16 changes: 16 additions & 0 deletions tests/errmsgs/tconflictingfields.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
discard """
errormsg: '''
The fields 'x' and 'y' cannot be initialized together, because they are from conflicting branches in the case object.
'''
"""

type
Foo = object
case kind: bool
of true:
x: int
of false:
y: int


var f = Foo(x: 1, y: 1)
Loading