Better error messages #195

Merged
sb10q merged 5 commits from error-messages into master 2022-02-22 15:04:47 +08:00

Fixes #44, #87, #109, #166, #190, #193

Examples:

RuntimeError: nac3 compilation failure: 
----------
Unknown type annotation at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 40 column 16: `InexistingException` is not registered in nac3, did you forgot to add @nac3?
----------
int32 is not callable (in /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 29 column 13)
----------
Incorrect argument type for n. Expected N, but got tuple[int32, bool] at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 34 column 25

Notes:
    N ∈ {int32, int64, float, bool}
----------
Tuple index must be a constant (KernelInvariant is also not supported) at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 24 column 15
----------
`list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9

Note that the error message order may not be deterministic.

For #90, the error message is now better, but I have not yet added float64 to the primitive types.

RuntimeError: type error inside object launching kernel: error when getting type of field `f` (<class 'numpy.float64'> is not supported in nac3 (did you forgot to put @nac3 annotation?))
Fixes #44, #87, #109, #166, #190, #193 Examples: ``` RuntimeError: nac3 compilation failure: ---------- Unknown type annotation at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 40 column 16: `InexistingException` is not registered in nac3, did you forgot to add @nac3? ---------- int32 is not callable (in /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 29 column 13) ---------- Incorrect argument type for n. Expected N, but got tuple[int32, bool] at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 34 column 25 Notes: N ∈ {int32, int64, float, bool} ---------- Tuple index must be a constant (KernelInvariant is also not supported) at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 24 column 15 ---------- `list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9 ``` Note that the error message order may not be deterministic. For #90, the error message is now better, but I have not yet added float64 to the primitive types. ``` RuntimeError: type error inside object launching kernel: error when getting type of field `f` (<class 'numpy.float64'> is not supported in nac3 (did you forgot to put @nac3 annotation?)) ```
pca006132 added 4 commits 2022-02-21 18:43:18 +08:00
`list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9

There is still this obscure "var72"...

``` `list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9 ``` There is still this obscure "var72"...

Note that the error message order may not be deterministic.

What about sorting by (filename, line, column)?

> Note that the error message order may not be deterministic. What about sorting by (filename, line, column)?
`list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9

There is still this obscure "var72"...

Because it is really a type variable that cannot be inferred. We can name this with something like a, b, c, d, but this is just the same. Name this with something like a, b, c, d may cause name collision between different threads or we will need to somehow synchronize them to share the name dictionary.

> ``` > `list[var72]::append` field does not exist at /home/pca006132/code/rust/nac3/nac3artiq/demo/demo.py: line 46 column 9 > ``` > > There is still this obscure "var72"... Because it is really a type variable that cannot be inferred. We can name this with something like a, b, c, d, but this is just the same. Name this with something like a, b, c, d may cause name collision between different threads or we will need to somehow synchronize them to share the name dictionary.

Note that the error message order may not be deterministic.

What about sorting by (filename, line, column)?

We can, but this will need another refactor because we have to make every error message a struct instead of a string. I planned to do so but there is just too many error messages around and hard to change this...

> > Note that the error message order may not be deterministic. > > What about sorting by (filename, line, column)? We can, but this will need another refactor because we have to make every error message a struct instead of a string. I planned to do so but there is just too many error messages around and hard to change this...

Just sort the strings then.

Just sort the strings then.
pca006132 added 1 commit 2022-02-22 14:33:59 +08:00

Just sort the strings then.

Done.

> Just sort the strings then. Done.
sb10q merged commit 3ad25c8f07 into master 2022-02-22 15:04:47 +08:00
sb10q deleted branch error-messages 2022-02-22 15:04:48 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#195
There is no content yet.