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

scilla-checker: Use JSON output format for type checking errors #1196

Open
jubnzv opened this issue Oct 27, 2022 · 0 comments
Open

scilla-checker: Use JSON output format for type checking errors #1196

jubnzv opened this issue Oct 27, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers tests

Comments

@jubnzv
Copy link
Contributor

jubnzv commented Oct 27, 2022

Currently, scilla-check cannot return typechecker warnings in JSON format.

We need this feature to write unit tests for contracts that don't pass type checking. This will allow us to test type checking errors in the imperative part of Scilla.

The problem is that we exit from the checker function here before generating a JSON from warnings here.

@jubnzv jubnzv added enhancement New feature or request good first issue Good for newcomers tests labels Oct 27, 2022
jubnzv added a commit that referenced this issue Jan 17, 2023
This PR introduces the `Return`  statement in the AST present with the `_return :=` construction in concrete syntax:

```
procedure foo() -> String
  a = my_string;
  _return := a;
end
```

Design decisions in the current implementation:
* `_return` takes as an argument a single variable with the return value. It seems natural to use this approach in the ANF-based language.
* Don't support empty return statements (`_return`) for early exit when the procedure has no a return type. e.g. the following code is forbidden:

```
procedure no_return()
  match something with
  | 0 => (* do something *)
  | _ => _return; (* typechecking error: cannot use an empty return for early exit *)
  end
end
```

Notes:
*  Gas cost of the return call is 1. 
*  We use cram tests to check the typechecker because of #1196

Closes #578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers tests
Projects
None yet
Development

No branches or pull requests

1 participant