Commit Graph

1917 Commits

Author SHA1 Message Date
KtorZ 00e9dabe82
Add missing Plutus builtins to Aiken's lang. 2023-02-22 12:53:03 +01:00
KtorZ 0838d48f7c
Move module name validation outside of type-checking
And disable it for documentation generation. This way, we can generate documentation for aiken/builtins and aiken (prelude)
2023-02-22 11:51:32 +01:00
KtorZ 6465af3ae2
Add missing keywords to highlightjs for doc generation. 2023-02-22 11:50:31 +01:00
KtorZ c0230a811f
Add 'plutusVersion' to blueprints. 2023-02-21 15:37:35 +01:00
KtorZ 82a32a082b
Remove 'purpose' from blueprint's schema.
This has been removed from the CIP-0057 specification since validators
  are often re-used for multiple purposes (especially validators with
  arity 2). It's misleading to assign a validator a purpose since the
  purpose distinction actually happens _within_ the validator itself.
2023-02-21 15:30:41 +01:00
KtorZ db0dfbbec1
Fix blueprint schema for tuples. 2023-02-21 15:29:33 +01:00
rvcas e611d1ee7a
chore(cmd::new): update validator definition in generated readme 2023-02-20 15:51:12 -05:00
rvcas 97f03e5e98 fix: variants no longer exist 2023-02-20 15:46:55 -05:00
rvcas 94ffc36442 chore: cargo fmt fix 2023-02-20 15:46:55 -05:00
rvcas bd93ced647 feat: improve validator arity check
* add count to dynamically adjust message
* check if args is greater than 3
* delete unused project level errors
2023-02-20 15:46:55 -05:00
rvcas 700e47d482 [create-pull-request] automated change 2023-02-20 15:33:03 -05:00
rvcas 6af6607df4 chore: github made a weird commit 2023-02-20 15:30:25 -05:00
rvcas 8b9991fd5b chore: update some strings 2023-02-20 15:30:25 -05:00
Lucas 4b296de27c Update crates/aiken-lsp/src/utils.rs
Co-authored-by: Matthias Benkort <5680256+KtorZ@users.noreply.github.com>
2023-02-20 15:30:25 -05:00
rvcas 52bb0e749e fix(lsp): cannot blindly run publish after handle_request 2023-02-20 15:30:25 -05:00
rvcas a8829889e3 feat(lsp): properly recompile project is files change 2023-02-20 15:30:25 -05:00
rvcas c033cab79e feat(lsp): bring over some stuff for completions, it basically doesn't work right though 2023-02-20 15:30:25 -05:00
rvcas 02eaefce21 feat(lsp): include docs on hover 2023-02-20 15:30:25 -05:00
rvcas 815d7d80c6 feat(lsp): hover and goto definition 2023-02-20 15:30:25 -05:00
rvcas 39ea803fe6 chore: remove eprintln 2023-02-20 15:30:25 -05:00
rvcas 38bcbaf701 feat(lsp): enable compiling a project 2023-02-20 15:30:25 -05:00
rvcas b55726c90f feat(project): remove Error::List and use Vec<Error> 2023-02-20 15:30:25 -05:00
Kasey White 70164282f8 fix: switch from unwrap to if let to allow boolean when
fix: test 67 fixed to take in ByteArray instead of string literal
2023-02-20 04:37:33 -05:00
Kasey White 2394438a91 clippy fix 2023-02-20 02:46:46 -05:00
Kasey White 87eb4ca3b4 feat: handle single constr when with multiple branches
Add case to acceptance test 40
Add special case for top level single constr in a when.
2023-02-20 02:46:46 -05:00
Matthias Benkort 95fce14b75
Merge pull request #391 from aiken-lang/string-and-bytearray-literals-iteration
String and bytearray literals iteration
2023-02-19 10:38:05 +01:00
KtorZ f307e214c3
Remove parse error on bytearray literals for trace, todo & error, parse as String instead.
This has been bothering me and the more I thought of it the more I
  disliked the idea of a warning. The rationale being that in this very
  context, there's absolutely no ambiguity. So it is only frustrating
  that the parser is even able to make the exact suggestion of what
  should be fixed, but still fails.

  I can imagine it is going to be very common for people to type:

  ```
  trace "foo"
  ```

  ...yet terribly frustrating if they have to remember each time that
  this should actually be a string. Because of the `trace`, `todo` and
  `error` keywords, we know exactly the surrounding context and what to
  expect here. So we can work it nicely.

  However, the formatter will re-format it to:

  ```
  trace @"foo"
  ```

  Just for the sake of remaining consistent with the type-system. This
  way, we still only manipulate `String` in the AST, but we conveniently
  parse a double-quote utf-8 literal when coupled with one of the
  specific keywords.

  I believe that's the best of both worlds.
2023-02-19 10:10:42 +01:00
KtorZ 78770d14b7
Emit warning when detecting an hex string interpreted as UTF-8 bytes.
This will probably save people minutes/hours of puzzled debugging. This is only a warning because there may be cases where one do actually want to specify an hex-encoded bytearray. In which case, they can get rid of the warning by using the plain bytearray syntax (i.e. as an array of bytes).
2023-02-19 10:10:42 +01:00
KtorZ d72e13c7c8
Emit parse error when finding a ByteArray literal instead of String literal. 2023-02-19 10:10:42 +01:00
KtorZ 5132110d4b
Fix acceptance tests to use new syntax. 2023-02-19 10:10:40 +01:00
KtorZ 53fb821b62
Use double-quotes for utf-8 bytearrays, and @"..." for string literals
The core observation is that **in the context of Aiken** (i.e. on-chain logic)
  people do not generally want to use String. Instead, they want
  bytearrays.

  So, it should be easy to produce bytearrays when needed and it should
  be the default. Before this commit, `"foo"` would parse as a `String`.
  Now, it parses as a `ByteArray`, whose bytes are the UTF-8 bytes
  encoding of "foo".

  Now, to make this change really "fool-proof", we now want to:

  - [ ] Emit a parse error if we parse a UTF-8 bytearray literal in
    place where we would expect a `String`. For example, `trace`,
    `error` and `todo` can only be followed by a `String`.

    So when we see something like:

    ```
    trace "foo"
    ```

    we know it's a mistake and we can suggest users to use:

    ```
    trace @"foo"
    ```

    instead.

  - [ ] Emit a warning if we ever see a bytearray literals UTF-8, which
    is either 56 or 64 character long and is a valid hexadecimal string.
    For example:

    ```
    let policy_id = "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6"
    ```

    This is _most certainly_ a mistake, as this generates a ByteArray of
    56 bytes, which is effectively the hex-encoding of the provided string.

    In this scenario, we want to warn the user and inform them they probably meant to use:

    ```
    let policy_id = #"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6"
    ```
2023-02-19 10:09:22 +01:00
KtorZ 98b89f32e1
Preserve bytearray format choice from input. 2023-02-19 10:09:22 +01:00
Kasey f3cdc05875
fix: the refactor on discharge value env (#393) 2023-02-18 20:49:29 -05:00
Matthias Benkort 1aea586cab
Merge pull request #390 from aiken-lang/acceptance-test-060--record-and-tuple-constants
Remove complex constants.
2023-02-17 18:20:39 +01:00
KtorZ cd4ceb219c
Remove complex and compound constants.
This is not supported by the code generation, so it's a bit of a lie
  to have them in the language in the first place. There's arguably not
  even any use for constant records, list and tuples to begin with. So
  this cleans this up everywhere for the sake of moving forward with the
  alpha release.

  This now reduces constants to:

  - Integer
  - ByteArray
  - String

  Anything else can be declared via a function anyway. We can revisit
  this choice later.... or not.
2023-02-17 17:31:15 +01:00
KtorZ 560c17d5aa
Add new acceptance test scenario: 060
```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/builder.rs:1088:13
    ╰─▶ not yet implemented
  ```
2023-02-17 17:13:04 +01:00
KtorZ c76c98f153
Merge branch 'expect-tuples' 2023-02-17 16:43:15 +01:00
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