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

Better error message for assignment at the end of an expression #3351

Open
ceedubs opened this issue Aug 23, 2022 · 0 comments
Open

Better error message for assignment at the end of an expression #3351

ceedubs opened this issue Aug 23, 2022 · 0 comments
Labels
error-message Request for improved error message

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Aug 23, 2022

If you accidentally end an expression/block with a variable assignment, the error message should be more helpful.

example

Here's an example of the current behavior (a trunk build from 2022-08-23):

scratch file

foo : Nat
foo =
  x = 3

ucm output

  I couldn't find any definitions matching the name _150003 inside the namespace .tmp
  
      3 |   x = 3
  
  Some common causes of this error include:
    * Your current namespace is too deep to contain the definition in its subtree
    * The definition is part of a library which hasn't been added to this project
  
  To add a library to this project use the command: `fork <.path.to.lib> .tmp.lib.<libname>`
  
  Whatever it is, its type should conform to Nat.

notes

This is especially easy to encounter when you are debugging code. Sometimes I'll find myself changing the last line of an expression from:

foo 3

to:

result = foo 3
trace "result" result
result

When I get done debugging I often remove the trace and the line below it and forget to change the result = foo 3 line to no longer perform assignment.

@ceedubs ceedubs added the error-message Request for improved error message label Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-message Request for improved error message
Projects
None yet
Development

No branches or pull requests

1 participant