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

Can we improve error message for wrong proc result type? #16150

Closed
StefanSalewski opened this issue Nov 26, 2020 · 2 comments · Fixed by #16152
Closed

Can we improve error message for wrong proc result type? #16150

StefanSalewski opened this issue Nov 26, 2020 · 2 comments · Fixed by #16152

Comments

@StefanSalewski
Copy link

type
  O = object
    i: int

proc p(str: string): seq[string] =
  return result

var o: O

o = p("hello")
nim c --gc:arc t.nim 
....
/tmp/hhh/t.nim(10, 6) Error: type mismatch: got <seq[string]> but expected 'O = object'
salewski@nuc /tmp/hhh $ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-11-12

In a similar but much more complicated case I got from the error message the impression that the argument of the proc has wrong type. Took me a few minutes to recognize that problem is the proc result.

Error pos column 6 is the start of the proc argument, and when argument and return types are both exotic types it is confusing.

@timotheecour
Copy link
Member

Error pos column 6 is the start of the proc argument, and when argument and return types are both exotic types it is confusing.

columns start at 0 but the point is indeed that the column isn't sufficient to disambiguate, you'll get the same column if you write o = p(12) (which in this case is a sigmatch error)

=> fixing this in #16152

timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 29, 2020
@Clyybber
Copy link
Contributor

columns start at 0

Nope, the issue here is that the error message is pointing to the call braces, not the sym of the callee.

timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 3, 2020
Araq pushed a commit that referenced this issue Dec 9, 2020
* fix #16150 improve type mismatch errors

* allow -d:nimLegacyTypeMismatch

* address comment
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
* fix nim-lang#16150 improve type mismatch errors

* allow -d:nimLegacyTypeMismatch

* address comment
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
* fix nim-lang#16150 improve type mismatch errors

* allow -d:nimLegacyTypeMismatch

* address comment
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.

3 participants