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.
```

(cherry picked from commit cdb750c962)
This commit is contained in:
ringabout
2025-09-15 21:04:35 +08:00
committed by narimiran
parent b5dd9735f4
commit f0b22a7620
2 changed files with 17 additions and 1 deletions

View File

@@ -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

View 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)