Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
timotheecour opened this issue Jan 7, 2020 · 2 comments · Fixed by #20931
Closed

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

timotheecour opened this issue Jan 7, 2020 · 2 comments · Fixed by #20931

Comments

@timotheecour
Copy link
Member

timotheecour commented Jan 7, 2020

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

@timotheecour timotheecour changed the title {.experimental: "dotOperators".} produce bad error msgs {.experimental: "dotOperators".} produce bad/misleading undeclared field error msgs Jan 7, 2020
@timotheecour timotheecour changed the title {.experimental: "dotOperators".} produce bad/misleading undeclared field error msgs dotOperators, callOperator produce bad/misleading undeclared field error msgs Feb 3, 2021
@timotheecour
Copy link
Member Author

@hlaaftana do you have any interest in working on this since you've looked at related code with #16924? this issue makes it awkward to use things like wrapnils or jsffi etc, since (even after your PR, albeit less so) you get bad errors

@treeform
Copy link
Contributor

I love dotOperators, except for this bug they are perfect. Can't wait for it to be fixed.

treeform added a commit to treeform/Nim that referenced this issue Nov 19, 2021
treeform added a commit to treeform/vmath that referenced this issue Nov 20, 2021
metagn added a commit to metagn/Nim that referenced this issue Nov 26, 2022
Araq pushed a commit that referenced this issue Nov 28, 2022
* better error messages for dot operators [backport]

fixes #13063

* also fixes #7777

* fix #6981 and #9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements
narimiran pushed a commit that referenced this issue Nov 30, 2022
* better error messages for dot operators [backport]

fixes #13063

* also fixes #7777

* fix #6981 and #9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements

(cherry picked from commit 555c5ed)
survivorm pushed a commit to survivorm/Nim that referenced this issue Feb 28, 2023
* better error messages for dot operators [backport]

fixes nim-lang#13063

* also fixes nim-lang#7777

* fix nim-lang#6981 and nim-lang#9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
* better error messages for dot operators [backport]

fixes nim-lang#13063

* also fixes nim-lang#7777

* fix nim-lang#6981 and nim-lang#9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements
bung87 pushed a commit to bung87/Nim that referenced this issue Jul 29, 2023
* better error messages for dot operators [backport]

fixes nim-lang#13063

* also fixes nim-lang#7777

* fix nim-lang#6981 and nim-lang#9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants