Commit Graph

148 Commits

Author SHA1 Message Date
rvcas
5e8edcb340 test(parser): finish moving tests to their correct modules 2023-07-04 17:48:48 -04:00
rvcas
47567c5e6f test(parser): some adjustments after rebase with @ktorz fix 2023-07-04 17:19:30 -04:00
rvcas
b25db429be test(parser): anon binop and ambiguous sequence 2023-07-04 17:19:30 -04:00
rvcas
8a6c81493c test(parser): record create 2023-07-04 17:19:30 -04:00
rvcas
a75bcff5c8 test(parser): type alias, anon fn, record update and more 2023-07-04 17:19:30 -04:00
rvcas
bd8c13c372 test(parser): move over the validator tests and some misc tests to parser 2023-07-04 17:19:29 -04:00
rvcas
6b05d6a91e test(parser): rename definitions to definition and more tests 2023-07-04 17:19:29 -04:00
rvcas
715752718d test: assert_module 2023-07-04 17:19:29 -04:00
rvcas
da0b969865 test: adjust snapshots 2023-07-04 17:19:29 -04:00
Cainã Costa
291dedf4e8 chore: refactor all parse tests to use assert_parse! 2023-07-04 17:19:28 -04:00
rvcas
f878ef7cef feat: move some token processing to the lexer 2023-07-04 17:19:28 -04:00
Cainã Costa
63cdb8aa09 chore: add more details on snapshot tests
We added a macro to add more information about the code that is being
tested, so we can add lots and lots of small snapshot tests.
2023-07-04 17:19:28 -04:00
Cainã Costa
eeaa1a05d2 feat: add first code snapshot test with insta 2023-07-04 17:19:28 -04:00
KtorZ
5a6cc855e6 Use byte count for token span in the lexer.
Somehow, miette doesn't play well with spans when using chars indices.
  So we have to count the number of bytes in strings / chars, so that
  spans align accordingly.
2023-07-04 16:51:59 -04:00
KtorZ
4252ee6373 Implement formatter for anon binop. 2023-06-17 08:44:59 +02:00
KtorZ
91f03abb7b Support all binary operator in the anonymous binop parser. 2023-06-17 08:44:45 +02:00
KtorZ
d0b4c1c3b5 Add remaining boolean comparison operator to anon binop parser.
Nothing to see here as they all have the same signature. Implementing
  arithmetic bin-operators and boolean logic operators will require some
  more logic.
2023-06-17 07:57:37 +02:00
KtorZ
ec94230294 Extend parser to accept anonymous binop as expressions.
This is simply a syntactic sugar which desugarize to a function call with two arguments mapped to the specified binary operator.
  Only works for '>' at this stage as a PoC, extending to all binop in the next commit.
2023-06-17 07:36:11 +02:00
KtorZ
ba911d48ea Refactor 'is_capture' field on function expressions.
Refactored into an enum to make it easier to extend with a new variant to support binary operators.
2023-06-17 07:26:46 +02:00
rvcas
aeaec6bcd8 fix: record format when module select
- instead of checking the container we need to check
  the FieldAccess label.

closes #601
2023-06-13 00:18:32 -04:00
KtorZ
6bd8e94e17 Preserve numeric underscore and hexadecimal notation through formatting. 2023-06-08 16:37:20 +02:00
KtorZ
0b7682306f Refactor formatter to use new 'self.int' helper function. 2023-06-08 15:34:28 +02:00
KtorZ
79a2174f0a Extend parser to support int as hexadecimal and numeric underscore.
We only allow numeric underscore for decimal numbers as I am not sure how we can define it for non-decimal numbers?
2023-06-08 15:33:50 +02:00
KtorZ
0ea11a4d13 Introduce new test cases for hexadecimal and underscore parsing. 2023-06-08 13:26:22 +02:00
rvcas
3fc9c8e0db chore: re-add empty line handling by @KtorZ
Co-authored-by: KtorZ
2023-06-07 17:21:04 -04:00
rvcas
1747090931 fix: fmt crashing with comment at end of file
closes #568
2023-06-07 15:59:54 -04:00
KtorZ
0afc3aba13 Fix operator precedences, in particular |>
Fixes #571.
2023-06-06 17:17:47 +02:00
rvcas
26a607eb00 fix: bad parsing of comments at end of file closes #551 2023-05-30 11:07:39 -04:00
rvcas
2860bac4c6 fix: bad parsing for module select type annotations closes #550 2023-05-30 10:39:49 -04:00
rvcas
7b3e1c6952 feat: adjust failing test syntax
* also add a formatter test
2023-05-25 18:21:12 -04:00
rvcas
a44b5e1a77 test: adjust formatter tests after latest tweaks 2023-05-25 17:37:53 -04:00
rvcas
a124a16a61 feat(tests): implement a way to express that tests can fail 2023-05-25 16:54:53 -04:00
microproofs
c2ee631d07 feat: new setup for the gen_uplc testing
* new test only module aiken_project::tests
* move TestProject to tests/mod.rs
* new tests go in gen_uplc.rs
2023-04-19 16:08:55 -04:00
microproofs
e4276d7f5a move uplc tests to new location 2023-04-19 16:08:55 -04:00
rvcas
3b351d36fb fix(aiken-lang): assignment as last expr in when and if 2023-04-16 19:55:47 -04:00
rvcas
98c61ca151 feat(aiken-lang): anonymous functions
@MartinSchere noticed a weird error
where an unknown variable wasn't being reported
the type checker was incorrectly scoping
arguments for anonymous function definitions.
Luckily his compilation failed due to a FreeUnique
error during code gen which is good. But this may
have been the source of other mysterious FreeUnique
errors.

I also noticed that anonymous function allowed
arguments with the same name to be defined.

`fn(arg, arg)`

This now returns an error.
2023-04-16 16:38:43 -04:00
rvcas
d8cbcde61d feat(validators): unused param warning
Params being unused were being incorrectly reported.
This was because params need to be initialized
at a scope above both the validator functions. This
manifested when using a multi-validator where one of
the params was not used in both validators.

The easy fix was to add a field called
`is_validator_param` to `ArgName`. Then
when infering a function we don't initialize args
that are validator params. We now handle this
in a scope that is created before in the match branch for
validator in the `infer_definition` function. In there
we call `.in_new_scope` and initialize params for usage
detection.
2023-03-30 21:15:27 -04:00
KtorZ
6a4f62d074 Allow newlines in when clause sequences. 2023-03-30 13:49:00 +02:00
KtorZ
5d4c95d538 Supports commenting validator inner functions. 2023-03-30 13:37:09 +02:00
KtorZ
814157dd7b Fix formatter inconsistency with record spread patterns. 2023-03-30 13:02:20 +02:00
KtorZ
17431daaa4 Correctly nest multiline pipeline expressions. 2023-03-30 12:48:15 +02:00
KtorZ
cc18e7cff2 Fix formatting of function expressions with traces
Fixes #471
2023-03-30 09:21:46 +02:00
KtorZ
0b8c3b05fe Fill-in test scenario for parsing large integer constants. 2023-03-18 16:17:42 +01:00
KtorZ
8a2af4cd2e Fix lexer throwing errors when parsing a too large tuple index. 2023-03-18 16:13:50 +01:00
rvcas
15bdb6972d feat(fmt): better validator formatting with double supported 2023-03-17 18:38:24 -04:00
rvcas
ed92869fb9 feat(validator): parsing and typechecking for double validators 2023-03-17 18:38:24 -04:00
KtorZ
28a3844d54 Cleanup implementation from multi-subjects when/is 2023-03-17 13:06:39 +01:00
KtorZ
c113582404 Support multi-clause patterns as syntactic sugar
And disable multi-patterns clauses. I was originally just controlling
  whether we did disable that from the parser but then I figured we
  could actually support multi-patterns clauses quite easily by simply
  desugaring a multi-pattern into multiple clauses.

  This is only a syntactic sugar, which means that the cost of writing
  that on-chain is as expensive as writing the fully expanded form; yet
  it seems like a useful shorthand; especially for short clause
  expressions.

  This commit however disables multi-pattern when clauses, which we do
  not support in the code-generation. Instead, one pattern on tuples for
  that.
2023-03-16 19:45:41 -04:00
KtorZ
660ca3fada Fix comment formatting wrongly assuming false invariant. 2023-03-16 18:44:11 -04:00
KtorZ
57e217e81c Add failing tests (fmt panic) on weird doc comments.
Isolated doc comments causes the compiler to panic with:

  ```
  'no consecutive empty lines'
  ```

  This is reproducible when doc comments are wrapped in sandwich between
  comments and newlines.
2023-03-16 18:44:11 -04:00