Commit Graph

1092 Commits

Author SHA1 Message Date
rvcas 22103739c3 chore: some clippy warnings 2022-12-23 15:52:44 -05:00
KtorZ 39f5d1a86d
Make build, check and docs target directory an (optional) argument
Instead of being an option. Feels more natural that way.
2022-12-23 20:23:27 +01:00
KtorZ b1b57406e7
Do not generate placeholder files when creating new projects.
And fix the --lib flag to be a flag.
2022-12-23 20:19:28 +01:00
Matthias Benkort f9ac12c3da
Merge pull request #212 from aiken-lang/better-type-check-errors
Better type check errors
2022-12-23 19:57:25 +01:00
KtorZ 7b9ea5dabb
Add links to the user-manual to errors, when applicable. 2022-12-23 19:50:14 +01:00
KtorZ 69f060e675
Rework all errors to provide better help text. 2022-12-23 19:27:06 +01:00
KtorZ c47c50ffb8
Show most type-checking error on a single line; reads better. 2022-12-23 00:25:18 +01:00
KtorZ ce0c6e0d0f
Use smart-constructor for UnexpectedLabeledArg errors.
Reduce duplications and keep the formatting of the error inside the error module.
2022-12-23 00:24:57 +01:00
KtorZ dca633da48
Refactor 'UnknownVariable' and 'UnknownTypeConstructor' as smart-constructor. 2022-12-23 00:09:07 +01:00
KtorZ aa2a235790
Suggest possible candidate on unknown imports.
## Before

  ```
  × Type-checking
  ╰─▶ Unknown module field 'ValidityRaneg' in module 'aiken/transaction'
  ```

  ## After

  ```
    × Type-checking
    ╰─▶ Unknown import 'ValidityRaneg' from module 'aiken/transaction'

     ╭─[../stdlib/validators/tmp.ak:2:1]
   2 │ use aiken/interval.{Interval, IntervalBound, IntervalBoundType}
   3 │ use aiken/transaction.{ScriptContext, ValidityRaneg}
     ·                                       ─────────────
   4 │
     ╰────
    help: Did you mean to import 'ValidityRange'?
  ```
2022-12-22 23:46:17 +01:00
KtorZ 70b1ec4324
Add function to calculate lenvenshtein distance of two strings
Will be useful to make import or usage suggestions.
2022-12-22 23:44:15 +01:00
KtorZ 666761efef
Make 'UnexpectedLabelArg' errors more helpful
## Before

  ```
   × Checking
   ╰─▶ Unexpected labeled argument

       t

     ╭─[/Users/mati/Devel/OpenSource/time_lock_aiken/validators/time_lock.ak:13:1]
  13 │   let now = when context.transaction.validity_range.lower_bound.bound_type is {
  14 │     Finite { t } -> t
     ·              ─
  15 │     NegativeInfinity -> 0
     ╰────
  ```

  ## After

  ```
    × Type-checking
    ╰─▶ Unexpected labeled argument 't'

      ╭─[../stdlib/validators/tmp.ak:10:1]
   10 │   let now = when context.transaction.validity_range.lower_bound.bound_type is {
   11 │     interval.Finite { t } -> t
      ·                       ─
   12 │     interval.NegativeInfinity -> 0
      ╰────
    help: The constructor 'Finite' does not have any labeled field. Its fields
          must therefore be matched only by position.

          Perhaps, try the following:

          ╰─▶  interval.Finite(t)
  ```
2022-12-22 21:45:49 +01:00
KtorZ 0682781460
Better errors when using unknown data-type constructor.
## Before

  ```
    × Checking
    ╰─▶ Unknown variable

            Finite

      ╭─[../stdlib/validators/tmp.ak:10:1]
   10 │   let now = when context.transaction.validity_range.lower_bound.bound_type is {
   11 │     Finite { t } -> t
      ·     ────────────
   12 │     NegativeInfinity -> 0
      ╰────
  ```

  ## After

  ```
    × Type-checking
    ╰─▶ Unknown data-type constructor 'Finite'

      ╭─[../stdlib/validators/tmp.ak:10:1]
   10 │   let now = when context.transaction.validity_range.lower_bound.bound_type is {
   11 │     Finite { t } -> t
      ·     ────────────
   12 │     NegativeInfinity -> 0
      ╰────
    help: Did you forget to import it?

          Data-type constructors are not automatically imported, even if their type is
          imported. So, if a module `aiken/pet` defines the following type:

           ┍━ aiken/pet.ak ━━━━━━━━
           │ pub type Pet {
           │   Cat
           │   Dog
           │ }

          You must import its constructors explicitly to use them, or prefix them
          with the module's name.

           ┍━ foo.ak ━━━━━━━━
           │ use aiken/pet.{Pet, Dog}
           │
           │ fn foo(pet : Pet) {
           │   when pet is {
           │     pet.Cat -> // ...
           │     Dog -> // ...
           │   }
           │ }
  ```
2022-12-22 19:34:50 +01:00
KtorZ 2aa4429231
Rename Unit -> Void 2022-12-22 18:52:28 +01:00
KtorZ 5cf9742e5e
Move tuple-index hint as diagnostic's help 2022-12-22 18:52:28 +01:00
Lucas 168196f903
Merge pull request #210 from aiken-lang/fix-if-expressions 2022-12-22 12:46:24 -05:00
KtorZ 1f15c2ca20
Sort import alphabetically when formatting.
Fixes #211.
2022-12-22 18:00:25 +01:00
rvcas c723f4f796 feat: redo the new command 2022-12-22 10:52:49 -05:00
KtorZ 1ca705005d
Fix formatting of if-expressions
Fixes #129.
2022-12-22 16:51:23 +01:00
Matthias Benkort a129a8a0d3
Merge pull request #208 from aiken-lang/tuple-when2
fix todo and list and tuple not equal operator
2022-12-22 10:28:06 +01:00
KtorZ 7ad8babf17
Rename ArgName::{Discard,NamedLabeled} as ArgName::{Discarded,Named}
Now that the other variants are gone, this is clearer.
2022-12-22 09:36:44 +01:00
KtorZ 8ab05509b1
Remove Named & DiscardLabeled, now unused
And unify everything into either 'Discard' or 'NamedLabeled'
2022-12-22 09:36:44 +01:00
Matthias Benkort 18acd0e65f
Merge pull request #202 from aiken-lang/tuple-indexes
Tuple indexes
2022-12-22 09:35:08 +01:00
KtorZ 4d74deb223
re-generate Cargo.lock 2022-12-22 09:15:26 +01:00
KtorZ 757428fa7f
Add new acceptance test scenario 033
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:523:17
    ╰─▶ not yet implemented: Tuple indexing not implementing yet
  ```
2022-12-22 09:14:23 +01:00
KtorZ bf7cdfba73
Implement parser & type-checker for tuple indexes.
```aiken
  fn foo() {
    let tuple = #(1, 2, 3, 4)
    tuple.1st + tuple.2nd + tuple.3rd + tuple.4th
  }
  ```
2022-12-22 09:14:23 +01:00
Kasey White b1dec1259d fix todo and list and tuple not equal comparator 2022-12-22 01:09:06 -05:00
rvcas 7867793bcd feat: on fmt if label and name are the same only print one 2022-12-21 19:17:15 -05:00
rvcas 4c4e454ea3 feat: all function args are now labeled implicitly 2022-12-21 19:17:15 -05:00
rvcas 42204d2d71 chore: make folder names match crate name 2022-12-21 18:11:07 -05:00
rvcas 5694cac1a5
chore: add ktorz to funding 2022-12-21 17:35:56 -05:00
rvcas 9028424a96 feat: rename Nil to Unit 2022-12-21 17:27:20 -05:00
rvcas 9df5005820 feat: add IData and BData builtins 2022-12-21 14:39:46 -05:00
rvcas 429126e38f feat: add trace 2022-12-21 14:39:46 -05:00
KtorZ 9068c89c00 Show trace logs as part of the test output when any.
```
  ┍━ test ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  │ PASS [mem: 6370, cpu: 2591822] trace_1
  │ ↳ is negative
  │ ↳ is non-negative
  ┕━━━━━━━━━ 1 tests | 1 passed | 0 failed
  ```
2022-12-21 14:39:46 -05:00
KtorZ 2fc14c7c1f Make box-drawing code more reusable
- Move it to 'pretty' module.
  - Have function work on colored strings titles and contents
2022-12-21 14:39:46 -05:00
KtorZ f26737ecb4 Remove the 'trace/try' keyword, use builtin.trace
I am not entirely sure what the intent was for that keyword, but
  nothing really matched between the parser, the formatter and the uplc
  code gen. I don't think there's any need for a keyword here, trace is
  already readily available from the builtins.
2022-12-21 14:39:46 -05:00
KtorZ 5d459b25bd Add new acceptance test scenario 032
```
  Error: aiken::parser

    × Parsing
    ╰─▶ Unexpected "try"

     ╭─[032/lib/test.ak:3:1]
   3 │ test trace_1() {
   4 │   builtin.trace("foo", True)
     ·           ─────
   5 │ }
     ╰────
    help: Try removing it
  ```
2022-12-21 14:39:46 -05:00
KtorZ 2aad1794a1
make dependencies optional in Aiken's manifest. 2022-12-21 14:32:40 +01:00
KtorZ 414a114530
fix acceptance tests manifest. 2022-12-21 14:06:46 +01:00
Matthias Benkort e6f4b378e1
Merge pull request #146 from aiken-lang/micah/file-errors
Raise more descriptive errors when the `aiken.toml` manifest is missing.
2022-12-21 11:05:02 +01:00
Micah Kendall bd816615d7
Display more descriptive error on missing manifest
Before:

  ```
  ❯ aiken check
  Error:
    × No such file or directory (os error 2)
  ```

  After:

  ```
  ❯ aiken check
  Error:
    × Missing 'aiken.toml' manifest in /Users/ktorz/Documents/Projects/aiken-lang/aiken
    help: Try running `aiken new <REPOSITORY/PROJECT>` to initialise a project with an example manifest.
  ```

  Co-authored-by: KtorZ <matthias.benkort@gmail.com>
2022-12-21 10:10:17 +01:00
Matthias Benkort 127581a445
Merge pull request #199 from aiken-lang/acceptance-test-021-type-alias-definition
Fix acceptance 021: allow registering type aliases in any order.
2022-12-21 10:07:03 +01:00
KtorZ 28c907d9de
Fix acceptance 021: allow registering type aliases in any order.
This is the most intuitive thing I could come up with: since the
  problem is mainly due to the order in which we try declaring the
  aliases, then it suffices to simply try as much as we can, and retry
  on failure until there's no more failure.

  Note that it's important to detect cycles if we do such thing (which
  we can by noticing that a given iteration didn't make any progress).

  It works pretty well in the end and even allow us to define a new kind
  of type error should there be a cyclic definition.
2022-12-21 09:43:37 +01:00
KtorZ a3591cc7dc
Fix 'aiken new', now require project name in specific format. 2022-12-21 00:19:24 +01:00
rvcas 796ac28044 feat: change the printing a little 2022-12-20 16:32:31 -05:00
rvcas 0b204beb58 chore: turn off cargo audit for now 2022-12-20 16:32:31 -05:00
rvcas e34cbc8e7e feat: compile deps 2022-12-20 16:32:31 -05:00
rvcas b06bf610b7 feat: dep downloading now works 2022-12-20 16:32:31 -05:00
rvcas 6a0b1ce5c3 feat: start trying to use deps 2022-12-20 16:32:31 -05:00