Commit Graph

11119 Commits

Author SHA1 Message Date
Richard Feldman
1865d96b05
Merge pull request #2005 from rtfeldman/MartinSStewart-patch-1
Fixed "map literal" used instead of "dict literal"
2021-11-17 19:50:50 -05:00
Folkert de Vries
7a41568fcd
Merge pull request #2004 from rtfeldman/contrain_expr2_letfunction
Implement constraint generation for annotated `Expr2::FunctionDefs`
2021-11-18 00:24:51 +01:00
Richard Feldman
6adbfbd245
Merge pull request #1998 from rtfeldman/roc-reporting-separate-module
Move reporting module into root.
2021-11-17 17:41:15 -05:00
Richard Feldman
380f8bceec
Merge pull request #1990 from rtfeldman/fix-dev-backend-readme-link
Fix link in gen_dev README.md
2021-11-17 17:29:19 -05:00
Brendan Hansknecht
09f030621c
Merge pull request #1992 from rtfeldman/dev-backend-num-int-negate
add x86_64 Int Num.neg support for gen_dev
2021-11-17 14:16:36 -08:00
Richard Feldman
1d330d9147
Merge pull request #1982 from rtfeldman/joshuawarner32/parser-snapshot-testing
Convert most test_parser tests to "snapshot" tests
2021-11-17 16:01:43 -05:00
MartinSStewart
46499e4419
Fixed "map literal" used instead of "dict literal" 2021-11-17 20:56:32 +01:00
Richard Feldman
2bb007e08b
Merge pull request #1987 from rtfeldman/builtins-list-split
Add builtin `List.split`
2021-11-17 13:41:58 -05:00
Folkert de Vries
71d38ecfab
Merge pull request #2000 from rtfeldman/wasm-str-builtins
gen_wasm: Get a Str builtin working, linking to roc_alloc
2021-11-17 19:38:23 +01:00
ayazhafiz
111a835b3c Add ignored tests for annotation-only declarations in Expr2
These tests fail currently because we have not implemented type
reconstruction in the presence of annonation-only declarations, but it's
good to keep track of them for later.
2021-11-17 13:38:00 -05:00
ayazhafiz
539c737123 Implement constraint generation for annotated Expr2::FunctionDefs
This is mostly the same as the procedure for unannotated `FunctionDef`s.
The only differences are that we need to

1. note the rigid type variables that are a part of the FunctionDef
2. generate fresh type variables for the function arguments, and
   constrain them to the types of the arguments passed to us in the
   annotation

This is enough to get the constraint generation working. There are more
interesting cases that properly typecheck in the main compiler but do
not typecheck given the current state of the editor AST (see the second
test in this commit), but this is a bug due to canonicalization, not
type reconstruction.
2021-11-17 13:38:00 -05:00
ayazhafiz
9399596d86 Store rigid var names during translation of closure defs to Expr2
We ened to store the mapping of `rigid type vars -> user-declared names`
for presentation later on when we reconstruct the type of an expression
and want to pretty-print it for the user. This information is most
naturally captured on `output.introduced_variables`, as the main
compiler does so there.

We don't currently record this mapping while translating `Annotation`s
to `Annotation2`s (though we could), so we store it when we hit an
annotated expression that now needs to become an `Expr2`.
2021-11-17 13:38:00 -05:00
ayazhafiz
477ecd6c3b Store rigid type and field names as Lowercase in Expr2
Moving from storing these as slices to `Lowercase`s makes it easier to
transform to shapes we'll need later during type reconstruction, for
example a mapping of rigid type variables to their lowercase variable
names.
2021-11-17 13:38:00 -05:00
ayazhafiz
efe6a8b7c8 Pass down rigids vars for substitution during type reconstruction
Rigid vars are added to types after solutions are already found and are
only relevant for pretty printing elaborated types, so we don't keep
track of/care about their rigid names until the end of solution.
Previously we didn't provide this information in tests, though - now we
do.
2021-11-17 13:38:00 -05:00
ayazhafiz
506086e3d7 Make sure Expr2 function annotation arguments fit in a PoolVec slot
The size of a `(PatternId, Type2)` tuple is 40 bytes (4 for the
`PatternId`, 4 bytes padding, 32 for the `Type2`). This doesn't fit in
an item slot allocated by the pool, which has a max of 32 bytes. So, we
allocate the Type2 itself on the pool, and then reference its pool ID in
the resulting tuple, which lowers the total size of the tuple to 8
bytes. This is a bit wasteful, but I couldn't find a better solution
without significantly more rework.

We also reorder the Type2 and PatternId fields in the tuple to better
align with the typical `(type|type variable, pattern|expression)` tuple
structure that exists in e.g. `FunctionDef::NoAnnotation`.
2021-11-17 13:38:00 -05:00
ayazhafiz
af8fad2618 Update sizes of Type2 variants to be correct
These are outdated; the new calculations reflect the current state of
the codebase.
2021-11-17 13:38:00 -05:00
Brian Carroll
3d124b4122 Fix builtin calls for primitives 2021-11-17 16:51:42 +00:00
Brian Carroll
dbd7d9a374 Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-str-builtins 2021-11-17 16:46:01 +00:00
Brian Carroll
b5b90fb2b7 Delete unused file 2021-11-17 16:45:52 +00:00
Brian Carroll
1134b6f45c Fix test_wrapper linking bug 2021-11-17 16:45:38 +00:00
hafiz
011e0050ae
Merge pull request #1995 from rtfeldman/contrain_expr2_letfunction
Implement constraint generation for Expr2::LetFunction
2021-11-17 10:24:20 -05:00
Brian Carroll
751bfd842c Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-str-builtins 2021-11-17 14:36:52 +00:00
hafiz
2f44383bb3
Merge branch 'trunk' into contrain_expr2_letfunction 2021-11-17 09:35:12 -05:00
Brian Carroll
64bb206d01
Merge pull request #1994 from rtfeldman/wasm-long-string-literal
Wasm long string literal
2021-11-17 14:15:53 +00:00
Brian Carroll
e75a9ec281 Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-str-builtins 2021-11-17 13:51:11 +00:00
Brian Carroll
a3bfee5cd8 Leave other string builtins for later 2021-11-17 13:48:29 +00:00
Brian Carroll
03c19b727a String concatenation working in gen_wasm! 2021-11-17 13:38:50 +00:00
Brian Carroll
a8f402d155
Merge branch 'trunk' into wasm-long-string-literal 2021-11-17 13:34:27 +00:00
Brian Carroll
9de989c0d5 Link wasm test binaries with libc.a 2021-11-17 12:54:39 +00:00
Brian Carroll
4aaa6d92a1 For now, commit a binary archive of Wasm libc 2021-11-17 12:52:48 +00:00
satotake
cef664165d
Merge branch 'trunk' into fix-dev-backend-readme-link 2021-11-17 19:39:33 +09:00
Brian Carroll
af896e5d33 Comments 2021-11-17 09:39:16 +00:00
Richard Feldman
8f25106b2c
Merge pull request #1986 from rtfeldman/valgrind_instr_fix
cli_run tests: valgrind unhandled insturction bytes
2021-11-16 20:32:39 -05:00
Brian Carroll
85855fc112 Merge branch 'wasm-long-string-literal' of github.com:rtfeldman/roc into wasm-long-string-literal 2021-11-16 23:41:31 +00:00
Brian Carroll
36f2ef301f Only enable wasm_str tests for gen-wasm feature 2021-11-16 23:41:15 +00:00
ayazhafiz
f342bb03af Resolve clippy lints 2021-11-16 16:20:40 -05:00
Lucas
ebc9d9836f
Merge branch 'trunk' into contrain_expr2_letfunction 2021-11-16 15:40:22 -05:00
ayazhafiz
3fe29c9949 Implement constraint generation for Expr2::LetFunction
We do this by treating function definition bodies as equivalent to
closures, and piggy-backing on existing work to generate constraints
over closures. Then, we just bind the function name with the resolved
type of the function body.

Support for constraint generation in the presence of annotated functions
will be added later.
2021-11-16 15:26:47 -05:00
Callum Dunster
f972098e70 Move reporting module into root. 2021-11-16 19:58:21 +01:00
Brian Carroll
28cf23d78a
Merge branch 'trunk' into wasm-long-string-literal 2021-11-16 17:40:11 +00:00
Richard Feldman
a0c292f7db
Merge pull request #1993 from rtfeldman/static_check_fix
added cfg to static size check for arm CPUs
2021-11-16 12:34:59 -05:00
ayazhafiz
b824302ab3 Name resolved type variables during Expr2 constrain testing
Prior to this patch we would not explicitly name solved type variables,
causing the elaborated type to appear unconstrained even when the
internal representation was constrained. For example, given a definition
like

```
\a, b -> Pair a b
```

we would generate distinct, fresh type variables for `a` and `b` but not
name them after solution. So even though the compiler knows they are
distinct, printing to the surface syntax would emit

```
*, * -> [ Pair * * ]*
```

which is incorrect, as the result type is constrained on the input type.
Instead, we now properly emit

```
a, b -> [ Pair a b ]*
```

naming variables where dependencies do exist. Where type variables are
don't constrain anything else, we can and do continue to emit the
wildcard type.
2021-11-16 11:56:39 -05:00
Anton-4
e20220634c
Merge branch 'trunk' into static_check_fix 2021-11-16 17:22:00 +01:00
Anton-4
2a4b3d3cd3 added cfg to static size check for arm CPUs 2021-11-16 16:56:05 +01:00
satotake
71bef85984 add x86_64 Int Num.neg support for gen_dev 2021-11-16 15:22:32 +00:00
satotake
c05f9dc1df
Fix link in gen_dev README.md 2021-11-17 00:15:27 +09:00
satotake
46e6e22776 use closure 2021-11-16 12:58:45 +00:00
Brian Carroll
5d4518c8d1 Try using C for the wasm test platform 2021-11-16 12:00:13 +00:00
Brian Carroll
b8f40011b9 Generate a test "platform" with libc allocator functions 2021-11-16 11:59:46 +00:00
Anton-4
0f064c121e
Merge branch 'trunk' into valgrind_instr_fix 2021-11-16 12:24:26 +01:00