Skip to content

Commit cdb750c

Browse files
authored
minor improvements of error messages of objvariants (#25040)
Because `prevFields` and `currentFields` have been already quoted by `'`, no need to add another. The error message was ``` The fields ''x'' and ''y'' cannot be initialized together, because they are from conflicting branches in the case object. ```
1 parent c49fb5a commit cdb750c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/semobjconstr.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ proc semConstructFields(c: PContext, n: PNode, constrCtx: var ObjConstrContext,
236236
let prevFields = fieldsPresentInBranch(selectedBranch)
237237
let currentFields = fieldsPresentInBranch(i)
238238
localError(c.config, constrCtx.initExpr.info,
239-
("The fields '$1' and '$2' cannot be initialized together, " &
239+
("The fields $1 and $2 cannot be initialized together, " &
240240
"because they are from conflicting branches in the case object.") %
241241
[prevFields, currentFields])
242242
result.status = initConflict
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
discard """
2+
errormsg: '''
3+
The fields 'x' and 'y' cannot be initialized together, because they are from conflicting branches in the case object.
4+
'''
5+
"""
6+
7+
type
8+
Foo = object
9+
case kind: bool
10+
of true:
11+
x: int
12+
of false:
13+
y: int
14+
15+
16+
var f = Foo(x: 1, y: 1)

0 commit comments

Comments
 (0)