mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 05:23:20 +00:00
minor improvements of error messages of objvariants
This commit is contained in:
@@ -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
|
||||
|
||||
16
tests/errmsgs/tconflictingfields.nim
Normal file
16
tests/errmsgs/tconflictingfields.nim
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user