stacks-network / clarity-wasm

`clar2wasm` is a compiler for generating WebAssembly from Clarity.
GNU General Public License v3.0
12 stars 9 forks source link

compile-time error handling #421

Open smcclellan opened 1 month ago

smcclellan commented 1 month ago

There are several places in the code where an InternalError is being thrown, wrapping an Unchecked. This should use the proper underlying error to match the interpreter instead.

csgui commented 1 month ago

Adding more details.

Consider the following expression, that should throw an error: (let ((map 2)) (+ map map)).

Such expressions cause the interpreter to throw an Unchecked(NameAlreadyUsed("map")) while the compiler is handling this error as a GeneratorError::InternalError(…).

The compiler should reflect how the interpreter handles the error. Ideally working with these errors from stacks-core.

The generic GeneratorError::InternalError(…) should really just be used for cases that we don't expect to show up.

Acaccia commented 4 weeks ago

@csgui @smcclellan I don’t understand this issue. Why does it exist, when #386 exists and was closed because we already have InternalErrors ?

csgui commented 4 weeks ago

@Acaccia I apologize that I closed issue #386 before an investigation into the need for an immediate work on compile-time errors. I should have reopened it instead. Let's consider this one for compilation-time error handling.