Commit Graph

1930 Commits

Author SHA1 Message Date
KtorZ 76b2396830
Fix offset location for 'SingleConstructorExpect' warnings. 2023-02-17 16:43:07 +01:00
KtorZ 92021e00b4
Merge branch 'parser-newline-comment-fix' 2023-02-17 14:08:20 +01:00
KtorZ 4a22e5f656
Fix module comment parsing / formatting after bumping chumsky to 0.9.0 2023-02-17 14:07:24 +01:00
KtorZ ec144fa220
Make 'choose_data' builtin available. 2023-02-17 11:25:41 +01:00
KtorZ f10e9e8977
Add new acceptance test scenario: 062
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/uplc/src/optimize.rs:16:68
    ╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "tests_bar", unique: Unique(1) })
  ```
2023-02-17 11:25:41 +01:00
KtorZ 95e1442b49 Swap arguments to unify when inferring traces
The first argument shows as what the compiler expects in the error message. So it must be the correct one or the error is actually misleading.
2023-02-16 20:29:41 -05:00
KtorZ 8fabfd112e Add new acceptance test scenario: 063 2023-02-16 20:29:41 -05:00
KtorZ 45454ced01 Make tracing configurable, when relevant.
Tracing is now turn OFF by default when:

  - building project
  - building documentation
  - building dependencies

  It can be turned ON only when building project using `--keep-traces`.
  That means it's not possible to build dependencies with traces. The
  address `--rebuild` flag will also rebuild without traces.

  Tracing is however turn ON by default when:

  - checking the project (and running tests).

  In this scenario, tracing can be disabled using `--no-traces` (if for
  example, one want to analyze the execution units of specific functions
  without having to manually remove traces from code).
2023-02-16 20:29:41 -05:00
KtorZ e9e3f4f50a Implement TraceIfFalse type-checking and AST transformation.
This caused me some trouble. In my first approach, I ended up having
  multiple traces because nested values would be evaluated twice; once
  as condition, and once as part of the continuation.

  To prevent this, we can simply evaluate the condition once, and return
  plain True / False boolean as outcome. So this effectively transforms any
  expression:

  ```
  expr
  ```

  as

  ```
  if expr { True } else { trace("...", False) }
  ```
2023-02-16 20:29:41 -05:00
KtorZ 6a50bde666 Implement parser & formater for 'TraceIfFalse'
Interestingly enough, chumsky seems to fail when given a 'choice' with
  more than 25 elements. That's why this commit groups together some of
  the choices as another nested 'choice'.
2023-02-16 20:29:41 -05:00
KtorZ 60390fe4f0 Add TraceIfFalse untyped expression
The goal is to handle this without bothering the code generation down the line. That is, we can handle it when transforming from the untyped AST to the typed one. That's why there's no 'TraceIfFalse' constructor in the typed AST. It has disappeared during type-check.
2023-02-16 20:29:41 -05:00
Kasey White 6ce62115f7 found formatting issue 2023-02-16 20:27:00 -05:00
Kasey White d7cfca2a57 fix condition and branch body getting passed same scope 2023-02-16 20:27:00 -05:00
Kasey White d1ca85c4bc feat: add support for assign and nested assign
My formatter is not working :'(
2023-02-16 20:27:00 -05:00
KtorZ e7a61df1f3 Add new acceptance test scenario: 062
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/uplc/src/optimize.rs:16:68
    ╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "tests_bar", unique: Unique(1) })
  ```
2023-02-16 20:27:00 -05:00
KtorZ 3204322da6
Fix validator lookup by title.
We want the lookup to yield a result when there's only a single
  validator; and no title is provided. So that users can simply do
  'aiken address' in their project if it's unambiguous. The validator's
  name is only required to disambiguate between multiple validators.

  I also noticed that the order of arguments in with_validator was
  wrong. Somehow.
2023-02-16 10:28:27 +01:00
KtorZ 20841962f6
Fix error messages still referring to blueprint's purpose. 2023-02-16 10:06:12 +01:00
Matthias Benkort ec6baf3a6a
Merge pull request #351 from aiken-lang/acceptance-test-054-pattern-match-on-list
Add new acceptance test scenario: 056
2023-02-16 10:01:56 +01:00
rvcas 2151fe4484 fix(infer): if branch bodies need to be checked in a new scope 2023-02-16 00:05:55 -05:00
rvcas c4a588f3dd test(check): if scoping 2023-02-16 00:05:55 -05:00
rvcas d41e6942c6 test: fix acceptance tests 2023-02-16 00:05:55 -05:00
rvcas 7b0faa7c1c test(check): validator errors and warning 2023-02-16 00:05:55 -05:00
rvcas a311531508 fix(cli): aiken address 2023-02-16 00:05:55 -05:00
rvcas 8b4985498b chore: add fmt test for validator 2023-02-16 00:05:55 -05:00
rvcas 2e78b7100c fix: blueprint tests 2023-02-16 00:05:55 -05:00
rvcas b057d27465 fix: some updates from latest main 2023-02-16 00:05:55 -05:00
rvcas 673b57b81c feat: get bluprint stuff compiling again 2023-02-16 00:05:55 -05:00
rvcas d03288cece feat(validator): move return type and arity check to infer 2023-02-16 00:05:55 -05:00
rvcas a88a193383 fix: properly lex new token and adjust parsed spans 2023-02-16 00:05:55 -05:00
rvcas e647330433 fix: better formating for validator 2023-02-16 00:05:55 -05:00
rvcas a044c3580e feat: typecheck validators 2023-02-16 00:05:55 -05:00
rvcas 2e7fe191db feat(definitions):
* add parsing for new validator defs
* start adding typechecking
* add a unit test for parsing
2023-02-16 00:05:55 -05:00
Kasey White 2fa494bda7 fix: calculated list pattern length with tail incorrectly before.
Now subtract 1 from length since next item does not need a end of list check
2023-02-15 22:12:41 -05:00
KtorZ d26ff0298f Add new acceptance test scenario: 054.
**a**

  ```
  × Main thread panicked.
  ├─▶ at crates/uplc/src/optimize.rs:16:68
  ╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "__other_clauses_delayed", unique: Unique(13) })
  ```

  **b**

  ```
  × Main thread panicked.
  ├─▶ at crates/aiken-lang/src/builder.rs:771:14
  ╰─▶ not yet implemented: Assign
  ```

  **c**

  ```
  × choice_4 failed
  help: ┍━ left ━━━━━━━━━━━━━┑
        │ (con data #d87a80) │
        ┕━━━━━━━━━━━━━━━━━━━━┙

        should be equal to

        ┍━ right ━━━━━━━━━━━━━━━━━━┑
        │ (con data #d8799f182aff) │
        ┕━━━━━━━━━━━━━━━━━━━━━━━━━━┙
  ```
2023-02-15 22:12:41 -05:00
Matthias Benkort dfe240ad64
Merge pull request #380 from aiken-lang/patch/cargo.nix
Update Cargo.nix
2023-02-16 00:51:50 +01:00
KtorZ 4d2d9319af [create-pull-request] automated change 2023-02-15 23:50:11 +00:00
Matthias Benkort 000a24b41c
Merge pull request #379 from aiken-lang/trace-rework-and-unification
Trace rework and unification
2023-02-16 00:48:13 +01:00
KtorZ 56258dc815
Fix todo/error parser on when clauses. 2023-02-16 00:40:49 +01:00
KtorZ 808ff97c68
Preserve trace, error & todo formatting. 2023-02-15 23:19:07 +01:00
KtorZ 6525f21712
Remove 'Todo' from the AST & AIR
Todo is fundamentally just a trace and an error. The only reason we kept it as a separate element in the AST is for the formatter to work out whether it should format something back to a todo or something else.

  However, this introduces redundancy in the code internally and makes the AIR more complicated than it needs to be. Both todo and errors can actually be represented as trace + errors, and we only need to record their preferred shape when parsing so that we can format them back to what's expected.
2023-02-15 21:57:08 +01:00
KtorZ 7b676643bd
Lift 'error' up one level in the parser and remove its label.
We now parse errors as a combination of a trace plus and error term. This is a baby step in order to simplify the code generation down the line and the internal representation of todo / errors.
2023-02-15 21:09:03 +01:00
KtorZ 7abd76b6ad
Allow to trace expressions (and not only string literals)
This however enforces that the argument unifies to a `String`. So this
  is more flexible than the previous form, but does fundamentally the
  same thing.

  Fixes #378.
2023-02-15 21:07:56 +01:00
KtorZ 4e51e49fe6
Align context diagnostics to use similar syntax. 2023-02-15 17:26:26 +01:00
KtorZ 7251b2d01e
Remove single-argument function call special-case in formatter
Not sure what this special case was trying to achieve, but it's not right. There's no need to handle function call with a single argument differently than the others.
2023-02-15 17:22:08 +01:00
KtorZ 47e77aa819
Add new context test for datums and reference scripts 2023-02-15 17:10:14 +01:00
KtorZ 6772e20d85
Replace withdrawals withdraw validator with always true validator. 2023-02-15 12:59:33 +01:00
KtorZ b300cf38db
Add new script context test scenario covering minting & values. 2023-02-15 12:49:56 +01:00
KtorZ cf7f206324
Add missing cbor-diag dependency for running acceptance tests. 2023-02-15 10:46:18 +01:00
KtorZ 014c7a3d73
Fix error display in tx simulate. 2023-02-15 09:42:46 +01:00
KtorZ 01c392836e
Fix CI script + add script interactions. 2023-02-15 09:42:46 +01:00