Skip to content

dotOperators, callOperator produce bad/misleading undeclared field error msgs #13063

@timotheecour

Description

@timotheecour

when a dotOperators is defined (with {.experimental: "dotOperators".}), it affects unrelated undeclared field error messages.

Example 1

{.experimental: "dotOperators".}
type Foo = object
template `.`(a: Foo, b: untyped): untyped = 123
type Bar = object
  x1: int
var b: Bar
echo b.x

Current Output

Error: type mismatch: got <Bar>
but expected one of:
template `.`(a: Foo; b: untyped): untyped
  first type mismatch at position: 1
  required type for a: Foo
  but expression 'b' is of type: Bar

expression: x(b)
  echo b.x

Expected Output

should contain the following errmsg which is what we get without template .(a: Foo, b: untyped): untyped = 123:

Error: undeclared field: 'x' for type t0892.Bar [declared in t0892.nim(11, 6)]
  echo b.x

in addition to the above errmsg Error: type mismatch: got <Bar>...

Example 2

callOperator has the same problems

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions