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

Improved errors #4

Open
matthew-healy opened this issue Oct 18, 2022 · 0 comments
Open

Improved errors #4

matthew-healy opened this issue Oct 18, 2022 · 0 comments

Comments

@matthew-healy
Copy link
Owner

matthew-healy commented Oct 18, 2022

Syntax Errors

Invalid Token

Example program

~

Error report

Syntax error - invalid token

  ┌─ file_name.uplp-0:1:1
  │
1 │ ~
  │ ^

You may wish to try deleting this character and running the program again.

Unexpected end of file

Example program

let x = 1

Error report

Syntax error - unexpected end of file

  ┌─ file_name.uplp-0:1:1
  │
1 │ let a = 1
  │          ^

I was looking for an "in" but I reached the end of the file without finding it.

Unexpected token

Example program

let x = 1 let y = 2 in y

Error report

Syntax error - unexpected token 'let'

  ┌─ file_name.uplp-3:1:11
  │
1 │ let x = 1 let y = 2 in y
  │           ^^^

I wasn't able to work out what you meant by this.

Type Errors

Type mismatch

Example program

1 + ()

Error report

Type error - type mismatch

  ┌─ file_name.uplp-3:1:11
  │
1 │ 1 + ()
  │     ^^

Expected a Num, but found Unit.

Evaluation Errors

Division by zero

Example program

let zero = 0 in 1 / zero

Error report

Evaluation error - division by zero

  ┌─ file_name.uplp-3:1:11
  │
1 │ let zero = 0 in 1 / zero
  │                 ^^^^^^^^

The above expression resulted in division by zero, which is invalid.
@matthew-healy matthew-healy changed the title Improved error formatting Improved errors Dec 30, 2022
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

No branches or pull requests

1 participant