Commit Graph

204 Commits

Author SHA1 Message Date
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 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
rvcas b3266fb837 chore: clippy warnings 2022-12-20 16:32:31 -05:00
Kasey White ac14512706 feat: fix nil equals nil, and fix funcs with discard params 2022-12-20 15:40:01 -05:00
Kasey White 9177267570 feat: test 24 passes
fixed issue with is_tuple in types
minor monomorphize change
2022-12-20 15:40:01 -05:00
Kasey White 17603e8cca checkpoint 2022-12-20 15:40:01 -05:00
Kasey White 43ff66cd01 all tests pass besides todo in 13, couple changes
Use more cost efficient recurse
Monomorphize needed to deal with function arg return types
bytearray variant added for variant names
2022-12-19 00:41:27 -05:00
Kasey White 421e7148d0 zero arg functions now work: test 15 2022-12-19 00:41:27 -05:00
Kasey White 3a765ddef5 add better todo 2022-12-19 00:41:27 -05:00
Kasey White eb386f4606 feat: Add nil support for test 19 2022-12-19 00:41:27 -05:00
Kasey White 5b908aaeb7 fix: fieldsexpose getting wrong generic id and not replacing type 2022-12-19 00:41:27 -05:00
Kasey White 47fae21af7 minor fix to monomorphize 2022-12-19 00:41:27 -05:00
Kasey White 2bce818110 chore: fix list insertion order, function insertion order,
and Inner function issues with variant
2022-12-19 00:41:27 -05:00
Kasey White e6c59dca2c cleanup if then else a bit 2022-12-19 00:41:27 -05:00
Kasey White eddd202253 tests 1 through 10 pass now, add negate 2022-12-19 00:41:27 -05:00
rvcas 841babae5c chore: clean some links up so they point to the new repo 2022-12-17 11:19:02 -05:00
KtorZ 202678e21e
Improve rendering of type-signatures in docs
- [x] Display function arguments using a newline-multiline strategy
    when the signature gets too long. For example:

    ```
    union_with
      ( left left: AssocList<key, value>
      , right right: AssocList<key, value>
      , with with: fn(key, value, value) -> value
      ) -> AssocList<key, value>
    ```

  - [x] Show type-aliases as type-aliases in signatures; provided
    they've been specified as type annotations. Otherwise, fallback to
    the inferred type.

  - [x] Do not show argument names in signatures, but show labels when
    they're present. This reflects more the original intent behind
    labels (which are meant as public-facing documentation).
2022-12-17 13:07:28 +01:00
KtorZ e1065e892a
Support module constants in docs. 2022-12-17 01:02:21 +01:00
KtorZ 873bd85d8b
Implement modules' extra, to get function & module comments in docs. 2022-12-17 01:02:21 +01:00
KtorZ b323c95241
Fix type-parameter pretty printing (use chevrons) 2022-12-17 01:02:20 +01:00
KtorZ d2c6d27545
Support data-types in documentation. 2022-12-17 01:02:20 +01:00
rvcas 0188003323 refactor: move helper option builder to lang 2022-12-15 13:28:30 -05:00
rvcas 42f8a694f4 tests: missing token broke a test 2022-12-15 11:12:35 -05:00
rvcas 53bc9aa56f fix: properly capture empty lines 2022-12-15 11:12:35 -05:00
KtorZ 5024bd884c
Remove debug line for pretty-printing test, and add '--debug' flag to 'check instead. 2022-12-15 02:02:10 +01:00
KtorZ e5972640d2
Remove 'eval' command.
Was introduced as a work-around to get some debugging info out of scripts, but tests do now provide the same capability with a better output and, do so automatically.
2022-12-14 22:14:35 +01:00
KtorZ 978a6c6981
Collect and display evaluation hints on test failures. 2022-12-14 22:00:56 +01:00
Kasey White 3c664b9651
test 1-9 passing 2022-12-14 09:45:26 +01:00
rvcas b71315ba2f
chore: trying to fix test 5 2022-12-14 09:45:26 +01:00
Kasey White 6635a918b5
clean up minor warnings 2022-12-14 09:45:26 +01:00
KtorZ b6962ba9d3
Add 'eval' command to evaluate target aiken function
Pretty useful for debbugging. Though, on second-thoughts, this is
  something we may want to review later and maybe have that done by
  default for tests.

  At the moment, we expects tests to unify to `bool`, and treat `false`
  values as failing tests. Yet, on failures, this gives little
  information about what's wrong with the test.

  It'd be nice to either have better way to assert in tests, or, to
  simply accept non-bool tests, and show whatever the test evaluates
  to as a debug output.
2022-12-14 09:45:26 +01:00
rvcas 11c793dd2a
feat(Type): add is_option method 2022-12-14 09:45:25 +01:00
Kasey White 8393d8555c
fill constants to data so now test 006 passes 2022-12-14 09:45:25 +01:00
Kasey White dc5ae296db
implement anonymous functions, more tests pass now 2022-12-14 09:45:25 +01:00
Kasey White d78e2c9c6f
feat: finish up generic match cases 2022-12-14 09:45:23 +01:00
Kasey White e43063d447
overhaul monomorphize to cover all generic cases
test b passes
2022-12-14 09:45:23 +01:00
Kasey White 15dc202810
Feat: generic function call tests work 2022-12-14 09:45:23 +01:00
Kasey White e4d9ca4586
support generics 2022-12-14 09:45:23 +01:00
rvcas 16fbf5bbcd
feat: fix recursive functions 2022-12-14 09:45:22 +01:00
Kasey White 3d3b3d7e10
checkpoint 2022-12-14 09:45:22 +01:00
KtorZ 95986fed83 Fix lexer for signed integers. 2022-12-13 19:52:30 -05:00
KtorZ 18bf89418a Fix codegen for binary operator 'or'
a && b → if a { b } else { false }
  a || b → if a { true } else { b }
2022-12-13 18:52:23 -05:00
KtorZ 431b0cfcf2 Preserve newlines after blocks of comments.
This is an example of output from the formatter now:

  ```
  //// Some module documentation

  // foo
  const a: Int = 42

  // Some comment block
  // For which newlines are respected.
  // Foo

  // Another one

  /// add_one documentation
  pub fn add_one(n: Int) -> Int {
    // n + 1
    n + 1
  }
  ```

  before this commit, comments would all be collapsed into one group
  above the function as:

  ```
  // Some comment block
  // For which newlines are respected.
  // Foo
  // Another one
  /// add_one documentation
  pub fn add_one(n: Int) -> Int {
  ```
2022-12-13 18:52:23 -05:00
KtorZ 22a526bb13 Enforce unique top-level names for tests too.
This prevents the compiler from crashing later on. Test names should be unique and not clash with function names.
2022-12-13 18:52:23 -05:00
rvcas 69db9696d6 feat: prefix tuples with hash again cause ambguity with call 2022-12-13 10:27:17 -05:00
rvcas 6dc4738b66 feat: update formatter for new changes 2022-12-12 19:22:11 -05:00
rvcas a4f6388eca feat: remove the need for # in front of tuples 2022-12-12 19:22:11 -05:00
rvcas dfc57b347a feat: switch generic type args to be delimited by chevrons 2022-12-12 19:22:11 -05:00
KtorZ 749d8ecb10
Fix formatter to not prefix tests as 'pub' 2022-12-09 14:35:50 +01:00
rvcas 384c4daa4a
feat: add test_gen function 2022-12-08 19:24:20 -05:00