Make 'field is not accessible' and 'field initialized twice' errors point to the field inside the obj construction (#24557)

Fixes two line infos to make the error's clearer inside editors

- 'field is not accessible' would point to the whole object construction
instead of just the field inside the construction
- 'field initialized twice' would point to the colon instead of the
field
This commit is contained in:
Jake Leahy
2024-12-23 00:25:36 +11:00
committed by GitHub
parent f29234b40f
commit 6bc52737b3
3 changed files with 28 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
type
PrivateField* = object
priv: string

View File

@@ -0,0 +1,23 @@
discard """
cmd: "nim check $file"
"""
import mobjconstr_msgs
block:
discard PrivateField(
priv: "test" #[tt.Error
^ the field 'priv' is not accessible]#
)
block:
type
Foo = object
field: string
discard Foo(
field: "test",
field: "test" #[tt.Error
^ field initialized twice: 'field']#
)