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

make usage of foo is a user-defined error more informative #13833

Merged

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Apr 1, 2020

/cc @Araq

before PR

procs marked with {.error.} give very uninformative/cryptic errors when used.

Example:

var a: seq[int]
echo a.isNil

t10464.nim(11, 8) Error: usage of 'isNil' is a user-defined error

totally cryptic, and we have no way to tell where this error comes from, especially in more complex cases where the type of a is generic, and there are many overloads.

after PR

we show where the symbol is defined, eg:
t10464.nim(11, 8) Error: usage of 'isNil' is an {.error.} defined at /Users/timothee/git_clone/nim/Nim_prs/lib/system.nim(1509, 1)

now it's clear: looking up the definition there shows:

proc isNil*[T](x: seq[T]): bool {.noSideEffect, magic: "IsNil", nilError.}

(and looking up {.nilError.} shows this resolves to {.error.})

@Araq Araq merged commit 216fd59 into nim-lang:devel Apr 1, 2020
@timotheecour timotheecour deleted the pr_fix_userdefined_errror_D20200331T155530 branch April 2, 2020 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants