Commit Graph

275 Commits

Author SHA1 Message Date
rvcas
87493bbba9 feat(register_values): refactor repeated code into register_function and register other_fun 2023-03-17 18:38:24 -04: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
KtorZ
0feb2df0a0 Minor error messages fixes. 2023-03-16 23:35:12 +01:00
Lucas
fab6d56bf2 Merge branch 'main' into newline-assignment 2023-03-16 15:30:55 -04:00
KtorZ
5d3816e984 Improve warning message for UnusedVariable 2023-03-16 15:29:44 -04:00
KtorZ
a5e505e6b0 Remove unused let-binding from type-checking
The typed-AST produced as a result of type-checking the program will
  no longer contain unused let-bindings. They still raise warnings in
  the code so that developers are aware that they are being ignore.

  This is mainly done to prevent mistakes for people coming from an
  imperative background who may think that things like:

  ```
  let _ = foo(...)
  ```

  should have some side-effects. It does not, and it's similar to
  assigned variables that are never used / evaluated. We now properly
  strip those elements from the AST when encountered and raise proper
  warnings, even for discarded values.
2023-03-16 15:29:44 -04:00
KtorZ
45ea7acc6a Refactor infer_assignment code to be more future-proof
It's generally a bad idea to use equality on enum variants because this won't trigger any compiler errors in the future yet could have hazardous effects if adding new variants. So it's usually preferrable to use exauhstive pattern matching and let the compiler warn missing cases in places where it matters.
2023-03-16 15:29:44 -04:00
KtorZ
5bea2d163d Fix comments and remove commented-out code. 2023-03-16 15:29:44 -04:00
KtorZ
da8d3fc1fc Removed unused warning variant: UnusedLiteral 2023-03-16 15:29:44 -04:00
KtorZ
20f5baffa7 Enforce newline after assignment / clause.
This leads to more consistent formatting across entire Aiken programs.
  Before that commit, only long expressions would be formatted on a
  newline, causing non-consistent formatting and additional reading
  barrier when looking at source code.

  Programs also now take more vertical space, which is better for more
  friendly diffing in version control systems (especially git).
2023-03-16 19:46:46 +01:00
KtorZ
d59305a1b0 Provide better compiler feedback for type holes in annotations.
It is now possible to leave a hole in a type annotation and have the compiler fill-in the expected type of us.
  This is a pretty useful debugging tool when playing with complex functions.
2023-03-16 14:07:06 +01:00
rvcas
bf94956c7e feat: print todo's type when printing the todo warning 2023-03-15 16:43:09 -04:00
Kasey White
f830172493 fix: wrong scope being passed in for unwrapdata and wrapdata in assignment ir
Closes #441
2023-03-14 17:05:27 -04:00
rvcas
2a00ef281b chore: bow to the clippy 2023-03-14 17:03:28 -04:00
KtorZ
724f1ac4b6 Remove unused 'FlexBreak'
The difference between 'FlexBreak' and 'Break(Mode::Strict/Flexible)' as always confused me; and turned out that the 'FlexBreak' thingy is never used. This is dead-code, so I removed it.
2023-03-14 16:47:43 -04:00
KtorZ
1311d9bd27 Support flexible pipe operator formatting
Rules are now as follows:

  - If a pipeline contains a newline, then the entire pipeline is formatted over multiple lines.
  - If it doesn't, then it's formatted as a single-line UNLESS it cannot fit; in which case, we fallback to multiline again.
2023-03-14 16:47:43 -04:00
Kasey White
4a7bbc23df fix: change in scope was applied in wrong place in pattern_ir for constr expect 2023-03-12 00:25:26 -05:00
rvcas
6440c4f498 fix(codegen): tuple pattern scopes
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-09 19:30:52 -05:00
Kasey White
f377d60085 ChooseData is now lazy with its branch arguments.
This enables calling the un_data builtins directly from choose_data args
2023-03-09 00:31:57 -05:00
rvcas
553eb88d3d fix(check): record field access properly restricted to single constr types 2023-03-08 23:50:16 -05:00
rvcas
41e725152e feat(unify): cannot cast between string and data closes #432 2023-03-08 22:47:38 -05:00
Kasey White
c85240cbed Fix exception when doing expect boolean = ..
Add new Air Assert Bool
Add acceptance test 76
2023-03-08 22:31:30 -05:00
KtorZ
0ea4538cac Fix typo and pluralize message for invalid field arity error. 2023-03-08 11:44:54 +01:00
Matthias Benkort
d8934b3d8d Merge pull request #421 from aiken-lang/monomorph-panic-fix
Functions with only a generic return weren't being properly monomorph…
2023-03-08 11:39:50 +01:00
Kasey White
89373c32e6 Functions with only a generic return weren't being properly monomorphized. Fixed that. 2023-03-08 10:31:05 +01:00
rvcas
bd7b8792bf feat: introduce EvalResult type 2023-03-08 10:19:36 +01:00
rvcas
1902a2d56c chore: update all deps 2023-03-06 13:13:59 -05:00
rvcas
1f8535e76e chore: update some deps 2023-03-06 11:09:44 -05:00
Kasey White
f230af436c fix: scope issue with expect and function calls
Add acceptance test 72
2023-03-03 01:00:35 -05:00
Kasey White
60bc2ab61d clippy 2023-03-02 21:49:20 -05:00
Kasey White
5779b77ccc fix: Had to also check for generic type in return of a function.
add check to prevent stack overflow error
Add panic to prevent any other occurrences of stack overflow
2023-03-02 21:49:20 -05:00
Kasey White
fe1f200e4d rename find_generics_... to find_and_replace_generics
Other renames as well
2023-03-02 21:49:20 -05:00
Kasey White
d7c33bd62a fix: A unique error was caused by the order in which we insert functions.
These functions relied on the same dependency and had the same scope. So insertion was by encounter rather than order determined by dependency handling. Now we switched to dependency order is prioritized to prevent free unique.
2023-03-01 14:22:59 -05:00
KtorZ
a46a9fca41 Only use colors & text decorations on ANSI-capable terminals.
Fixes #404.
2023-02-26 13:19:03 +01:00
Kasey White
2f2be39813 clippy fixes 2023-02-26 00:13:38 -05:00
Kasey White
665a8dec67 feat: add support for unconstr_data
-Builitins IR now acts like Record IR in terms of argument consumption
-UnConstrData returns as Pair(Data,Data) to conform with how pairs are treated behind the scenes.
2023-02-26 00:13:38 -05:00
rvcas
0066cc61cc Release 0.0.29
aiken@0.0.29
aiken-lang@0.0.29
aiken-lsp@0.0.29
aiken-project@0.0.29
uplc@0.0.29

Generated by cargo-workspaces
2023-02-23 19:04:18 -05:00
KtorZ
539ed2dea4 Fix unicode char parsing in comments. 2023-02-22 17:33:13 +01:00
KtorZ
bdee5e7995 Use variable-length threshold for levenshtein distance
Fixes #348
2023-02-22 13:29:39 +01:00
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
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
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
02eaefce21 feat(lsp): include docs on hover 2023-02-20 15:30:25 -05:00