Commit Graph

1648 Commits

Author SHA1 Message Date
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
KtorZ
e1c0c3986d Remove unused imports in 054. 2023-02-15 09:42:45 +01:00
Kasey White
a24fc55993 Delay 2nd arg on trace in case it throws and prevents trace from printing 2023-02-15 03:06:58 -05:00
Kasey White
e15e725bfe add one more test 2023-02-15 02:20:05 -05:00
Kasey White
5e5a9dd25f quick fix for test 59 2023-02-15 02:20:05 -05:00
Kasey White
32b0200966 fixes: tuple clauses, zero args funcs, list clause named pattern
List Clauses patterns handle var cases

Fixed Tuple Clauses issue with last clause not being a tuple

Redid how zero arg functions and dependencies are handled. Tough one lol
2023-02-15 02:20:05 -05:00
KtorZ
23bf101e08 Add new acceptance test scenario: 058
Doesn't like var patterns in list pattern-matching

  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:770:29
    ╰─▶ internal error: entered unreachable code
  ```
2023-02-15 02:20:05 -05:00
KtorZ
d9cfad8f68 Add new acceptance test scenario: 061
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/uplc/src/optimize.rs:16:68
    ╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "tests_tx_1", unique:
        Unique(14) })
  ```
2023-02-15 02:20:05 -05:00
KtorZ
6132c092e3 Add new acceptance test scenario: 059
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:1451:52
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```

  See also: #310
2023-02-15 02:20:05 -05:00
Kasey White
b7fa57027a scope is now properly handled in expect cases 2023-02-14 12:38:36 -05:00
Lucas
d8ff9e23a4 Merge pull request #373 from aiken-lang/test-script-context-interactions
Test (some) script context interactions
2023-02-14 12:03:04 -05:00
KtorZ
428b5f2b37 Align output of tx simulate with other Aiken's commands.
And also return a structured output as JSON, so it's more easily used
  by other tools.

  ```
       Parsing script context
    Simulating 78ec148ea647cf9969446891af31939c5d57b275a2455706782c6183ef0b62f1
      Redeemer Spend → 0

  {"mem":151993,"cpu":58180696}
  ```
2023-02-14 16:50:55 +01:00
KtorZ
a3078adce8 Add succinct README to explain what's going on. 2023-02-14 16:25:48 +01:00
KtorZ
685473ead6 Rename data -> ctx 2023-02-14 16:11:00 +01:00
KtorZ
5369872a3d Add new script_context acceptance scenario for withdrawals. 2023-02-14 16:11:00 +01:00
KtorZ
34596b3084 Fix collecting withdrawal scripts in eval_phase_one
The current implementation assumed that ALL withdrawals present in a
  transaction had to be locked by a script and failed otherwise. But a
  transaction can actually be composed of both. So instead of failing,
  we should rather just ignore withdrawals that can't be referenced by
  redeemers.
2023-02-14 15:58:34 +01:00
KtorZ
251aa756d9 Make basic script a template, and add more assertions. 2023-02-14 11:37:10 +01:00
KtorZ
545323128c Write basic e2e validator with evaluation. 2023-02-14 10:39:31 +01:00
KtorZ
4ef1ba69de Use blueprint in hello-world example. 2023-02-14 09:16:30 +01:00
Kasey White
3b3ec7d95c format fix 2023-02-12 19:12:38 -05:00
Kasey White
765ceefd38 feat: add ability to downcast void to data 2023-02-12 18:56:38 -05:00
Kasey White
4c838defd1 fix issue with final clause producing clauseguard air 2023-02-12 18:43:11 -05:00
Kasey White
e9883adf12 fix: scope issue when using when with a function call subject 2023-02-12 18:43:11 -05:00
KtorZ
2bda581fbd Add new acceptance test scenario: 057
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:4286:48
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```
2023-02-12 18:43:11 -05:00
Kasey White
1c9540ec87 one more test case to add 2023-02-11 22:26:34 -05:00
Kasey White
4b1015e0d4 change how expect works on lists and constructors
Add more coverage to acceptance test 40 on expect
2023-02-11 22:26:34 -05:00
Matthias Benkort
deb2ab8f80 Merge pull request #362 from aiken-lang/patterns-improvements
Patterns improvements
2023-02-11 22:46:04 +01:00
KtorZ
b83a247ff7 Add slightly more informative note for list pattern on int. 2023-02-11 17:00:32 +01:00
KtorZ
2e8fd6e1c2 Remove patterns on 'String'
There's arguably no use case ever for that in the context of on-chain
  Plutus. Strings are really just meant to be used for tracing. They
  aren't meant to be manipulated as heavily as in classic programming
  languages.
2023-02-11 16:57:14 +01:00
KtorZ
6649821200 Add type-checker sanity tests for list patterns. 2023-02-11 16:54:49 +01:00
KtorZ
56e90fba21 Add missing newlines to 'join' in error messages. 2023-02-11 16:24:56 +01:00
KtorZ
3c7663cd3c Basic exhaustivness check on list patterns
Before that commit, the type-checker would allow unsafe list patterns
  such as:

  ```
  let [x] = xs

  when xs is {
    [x] -> ...
    [x, ..] ->  ...
  }
  ```

  This is quite unsafe and can lead to confusing situations. Now at
  least the compiler warns about this. It isn't perfect though,
  especially in the presence of clause guards. But that's a start.
2023-02-11 16:20:28 +01:00
rvcas
831a37d094 feat: shouldn't use this warning on list 2023-02-11 09:42:39 -05:00