Commit Graph

1014 Commits

Author SHA1 Message Date
rvcas
f94e40daf4 fix: more test and issues with scoping/names 2024-08-25 16:20:03 +02:00
rvcas
cf3180996a fix: map fallback name if present to else 2024-08-25 16:20:03 +02:00
rvcas
00907c2bcc fix: format snapshot tests 2024-08-25 16:20:03 +02:00
rvcas
7f26db401c feat: handler implicit some and none 2024-08-25 16:20:03 +02:00
rvcas
6b8be61b6e test: new snapshots for parsing v3 validators 2024-08-25 16:20:03 +02:00
rvcas
0d8d80e5a7 feat: transform TypedValidator in a function of handlers 2024-08-25 16:20:03 +02:00
rvcas
471bbe2175 feat: append validator name to handlers 2024-08-25 16:20:02 +02:00
rvcas
b984f0455a feat: return a vec instead of Option 2024-08-25 16:20:02 +02:00
rvcas
4287fa3f4a feat: new formatting for validators v3 2024-08-25 16:20:02 +02:00
rvcas
9e866a5ec1 fix: make sure that fallback gets it's own scope with params 2024-08-25 16:20:02 +02:00
rvcas
1d9034573b feat: impl infer for new validators 2024-08-25 16:20:02 +02:00
rvcas
fff90f7df5 feat: fix inference comp issues 2024-08-25 16:20:02 +02:00
rvcas
0de5cbc74e feat: implement new validator parsing 2024-08-25 16:20:01 +02:00
KtorZ
9aa9070f56 Revise desugaring following feedback
- We now consistently desugar an expect in the last position as
    `Void`. Regardless of the pattern. Desugaring to a boolean value is
    deemed too confusing.

  - This commit also removes the desugaring for let-binding. It's only
    ever allowed for _expect_ which then behaves like a side effect.

  - We also now allow tests to return either `Bool` or `Void`. A test
    that returns `Void` is treated the same as a test returning `True`.
2024-08-23 16:04:40 +02:00
KtorZ
fbe6f02fd1 Allow assignment as last expression
This is debatable, but I would argue that it's been sufficiently
  annoying for people and such a low-hanging fruit that we ought to do
  something about it.

  The strategy here is simple: when we find a sequence of expression
  that ends with an assignment (let or expect), we can simply desugar it
  into two expressions: the assignment followed by either `Void` or a
  boolean.

  The latter is used when the assignment pattern is itself a boolean;
  the next boolean becomes the expected value. The former, `Void`, is
  used for everything else. So said differently, any assignment
  implicitly _returns Void_, except for boolean which return the actual
  patterned bool.

  <table>
  <thead><tr><th>expression</th><th>desugar into</th></tr></thead>
  <tbody>
  <tr>
  <td>

  ```aiken
  fn expect_bool(data: Data) -> Void {
    expect _: Bool = data
  }
  ```
  </td>
  <td>

  ```aiken
  fn expect_bool(data: Data) -> Void {
    expect _: Bool = data
    Void
  }
  ```
  </td>
  </tr>
  <tr>
  <td>

  ```aiken
  fn weird_maths() -> Bool {
    expect 1 == 2
  }
  ```
  </td>
  <td>

  ```aiken
  fn weird_maths() -> Bool {
    expect True = 1 == 2
    True
  }
  ```
  </td>
  </tr>
  </tbody>
  </table>
2024-08-23 16:04:39 +02:00
KtorZ
0f905045e7 Rename mk_nil_data, mk_pair_data & mk_nil_pair_data builtins. 2024-08-23 10:39:37 +02:00
KtorZ
5067aad0d8 Fix 'Pair' formatter inside forced unbroken components. 2024-08-13 17:05:41 +02:00
KtorZ
f56b9bbbc7 Rename function variable in parser
Better reflect its actual semantic. The name probably slipped through a wrong copy pasting.
2024-08-13 10:56:28 +02:00
Riley-Kilgore
cab58e5aab One other place 2024-08-12 17:57:54 -04:00
Riley-Kilgore
213ad48de7 Fixed span calculation for backpassing (sort of) 2024-08-12 17:57:54 -04:00
Matthias Benkort
eb4a43719c Merge pull request #998 from aiken-lang/riley/misc-hover
Added more granularity to find_node for Fn
2024-08-12 02:16:38 +02:00
Riley-Kilgore
52c8ca6cee Added fix to Fn find_node 2024-08-08 17:15:28 -07:00
microproofs
72059eacee Fix: Recursion issue where the static param optimization on recursive functions that were passed as arguments to other functions 2024-08-08 19:36:16 -04:00
microproofs
0800901135 Fix clippy 2024-08-08 00:39:44 -04:00
microproofs
51fd503317 warning fix 2024-08-08 00:39:44 -04:00
microproofs
0a1992acd2 Run acceptance tests 2024-08-08 00:39:44 -04:00
microproofs
56ff4ec678 Fixing other tests 2024-08-08 00:39:44 -04:00
microproofs
33370b8637 Fix minor issues found when testing 2024-08-08 00:39:44 -04:00
KtorZ
f5c4e185d4 Redact compiledCode & hash in generated blueprint tests
The point of those tests is to ensure that blueprints are generated
  properly, irrespective of the generated code. It is annoying to
  constantly get those test failing every time we introduce an
  optimization or something that would slightly change the generated
  UPLC.
2024-08-08 00:39:44 -04:00
microproofs
8a461d5bd5 Few minor changes, clippy fixes, and test fixes 2024-08-08 00:39:44 -04:00
microproofs
4cf81a19b1 Update most of the tests and builder functions to use the new delay_branch_functions 2024-08-08 00:39:44 -04:00
microproofs
d7e9fef4d3 Create new helper functions to take care of force and delaying branch terms 2024-08-08 00:39:44 -04:00
KtorZ
23a3134642 Rework choose_data_xxx API to include force/delay inside functions. 2024-08-08 00:39:44 -04:00
microproofs
d23a5b2f11 Fix test for expect_head_cast_data_with_tail 2024-08-08 00:39:44 -04:00
KtorZ
021679b8ac Force unwrap_xxx_or inside function body
Otherwise, it becomes the responsibility of the caller to force the result; which may be easily forgotten.
2024-08-08 00:39:44 -04:00
microproofs
a132a2e486 Fix unwrap issues 2024-08-08 00:39:44 -04:00
KtorZ
aefbc6e1b9 Define a safer API for unwrap_xxx_or and choose_data_xxx
Cloning a 'Term' is potentially dangerous, so we don't want this to
  happen by mistake. So instead, we pass in var names and turn them into
  terms when necessary.
2024-08-08 00:39:44 -04:00
KtorZ
9610237616 Refactor unknown_data_to_type, break down into smaller functions. 2024-08-08 00:39:44 -04:00
KtorZ
c3a61706b5 Factor out common UPLC logic for converting Data to Bool. 2024-08-08 00:39:44 -04:00
microproofs
05504b9762 Fix out of order expect check. Also fix no_inline error in code gen. @acceptance_107 2024-08-08 00:39:44 -04:00
microproofs
663695558c Fix remaining errors and now onto testing 2024-08-08 00:39:44 -04:00
microproofs
0be5229f1c Only 2 errors and todos left to finish 2024-08-08 00:39:44 -04:00
microproofs
6ba9a312f0 Work through all but constr case for expect_type_assign
TODO: constr case for expect_type_assign
TODO: soft_cast opcode uplc codegen
TODO: fix PairAccessor opcode uplc codegen
2024-08-08 00:39:44 -04:00
microproofs
dd5badd884 Start work on revamping assignment so we can handle soft casting properly 2024-08-08 00:39:44 -04:00
KtorZ
a6c5dbb5ad Thread down if/is pattern assignment type down to code-generation.
This isn't sufficient however, as the 'assignment' helper handling
  code generation doesn't perform any check when patterns are vars. This
  is curious, and need to be investigated further.
2024-08-08 00:39:44 -04:00
KtorZ
aa872846bb Re-generate insta snapshots, remove obsolete snapshots. 2024-08-06 19:25:35 +02:00
KtorZ
9d8fdf787c Improve formatter on long-lines, in particular bin-ops. 2024-08-06 19:25:35 +02:00
KtorZ
91e0e2493a Provide better errors on unknown type in cyclic definitions.
Let's consider the following case:

  ```
  type Var =
    Integer

  type Vars =
    List<Var>
  ```

  This incorrectly reports an infinite cycle; due to the inability to
  properly type-check `Var` which is also a dependent var of `Vars`. Yet
  the real issue here being that `Integer` is an unknown type.

  This commit also upgrades miette to 7.2.0, so that we can also display
  a better error output when the problem is actually a cycle.
2024-08-06 19:24:48 +02:00
KtorZ
1ae6640cd0 Make alternative clause parser more flexible.
The spirit here is to make it easier to discover this syntax. People
  have different intuition about it and the single pipe may not be the
  most obvious one.

  It is however the recommended syntax, and the formatter will rewrite
  any of the other to it.
2024-08-06 11:31:11 +02:00
KtorZ
8c121f6d97 Document 'export' and provide better errors on module not found. 2024-08-06 11:09:05 +02:00