Commit Graph

2893 Commits

Author SHA1 Message Date
Folkert
3720c38e2b
convert to pointer_cast where we can 2022-12-17 23:21:19 +01:00
Ayaz
ac532791eb
Merge pull request #4778 from joshuawarner32/fix-record-unification 2022-12-17 16:20:51 -06:00
Folkert
8e36456765
de-duplicate tag extract value code 2022-12-17 22:56:05 +01:00
Folkert
551a0aa6db
subtle lifetime issue on a pointer 2022-12-17 22:49:36 +01:00
Folkert
8eddffeb70
clarify variable name 2022-12-17 22:24:55 +01:00
Folkert
78e0a4ca6b
use load_roc_value 2022-12-17 22:24:41 +01:00
Folkert
1d260530fb
print a prettier command string 2022-12-17 22:21:00 +01:00
Folkert
a522d49558
backport some changes needed for zig 10 2022-12-17 22:17:27 +01:00
Joshua Warner
174f7d5e4d
Fix bug in unifying records
This was leading us to have an infinitely-recursive type, which eventually causes layout to stack-overflow

Fixes #4739
2022-12-17 11:37:19 -08:00
Joshua Warner
a046428ce6
Add fuzzing for the formatter and fix bugs
This commit adds fuzzing for the (expr) formatter, with the same invariants that we use for fmt tests:
  * We start with text, which we parse
  * We format the AST, which must succeed
  * We parse back the AST and make sure it's identical igoring whitespace+comments
  * We format the new AST and assert it's equal to the first formatted version ("idempotency")

Interestingly, while a lot of bugs this found were in the formatter, it also found some parsing bugs.

It then fixes a bunch of bugs that fell out:
* Some small oversights in RemoveSpaces
* Make sure `_a` doesn't parse as an inferred type (`_`) followed by an identifier (parsing bug!)
* Call `extract_spaces` on a parsed expr before matching on it, lest it be Expr::SpaceBefore - when parsing aliases
* A few cases where the formatter generated invalid/different code
* Numerous formatting bugs that caused the formatting to not be idempotent

The last point there is worth talking further about. There were several cases where the old code was trying to enforce strong
opinions about how to insert newlines in function types and defs. In both of those cases, it looked like the goals of
(1) idempotency, (2) giving the user some say in the output, and (3) these strong opinions - were often in conflict.

For these cases, I erred on the side of following the user's existing choices about where to put newlines.

We can go back and re-add this strong opinionation later - but this seemed the right approach for now.
2022-12-17 09:52:09 -08:00
Richard Feldman
10c8523888
Handle FileProblem explicitly 2022-12-17 03:57:11 -05:00
Richard Feldman
ed0b07a62f
clippy 2022-12-17 03:35:39 -05:00
Richard Feldman
3e448fd2b4
Merge remote-tracking branch 'origin/main' into packages 2022-12-17 03:32:52 -05:00
Richard Feldman
b21a3a4fdb
Handle loading errors more consistently 2022-12-17 03:31:10 -05:00
Richard Feldman
7b85775ee6
Drop a dbg! 2022-12-16 12:30:38 -05:00
Richard Feldman
27fc823795
Drop a redundant Instant::now() 2022-12-16 12:27:22 -05:00
Brian Carroll
62269bf6c9
builtins: build the Wasm interpreter from inside run-wasm-tests.sh 2022-12-16 16:05:00 +00:00
Brian Carroll
4d5b7f8b73
wasm_interp: add a WasmModule to Instance so we don't have to pass it to call_export 2022-12-16 14:52:10 +00:00
Brian Carroll
86a82f8576
test_gen: disable roc_wasm_interp logging 2022-12-16 14:52:10 +00:00
Brian Carroll
b73e022336
test_gen: update WasiDispatcher 2022-12-16 14:52:10 +00:00
Brian Carroll
d389601035
Merge branch 'main' of github.com:roc-lang/roc into wasm_interp_test_gen 2022-12-16 14:50:09 +00:00
Brendan Hansknecht
faaa466c70
Merge pull request #4774 from roc-lang/enable-fuzzing
[simple PR] Enable fuzzing and sanitizers
2022-12-16 00:22:00 +00:00
Folkert de Vries
f550f049db
Merge pull request #4768 from roc-lang/expects-store-specialized-variable
Support using dbg/expect in polymorphic functions
2022-12-16 00:10:40 +01:00
Richard Feldman
e9e82ddc08
Merge pull request #4766 from roc-lang/remove-f128
remove F128
2022-12-15 17:59:48 -05:00
Richard Feldman
94818fc6cc
Create header messages for packages 2022-12-15 17:45:32 -05:00
Brendan Hansknecht
d33e0a9f19
add links to docs 2022-12-15 14:45:25 -08:00
Brendan Hansknecht
1878250e36
add message about supported sanitizers 2022-12-15 14:43:52 -08:00
Brendan Hansknecht
bf9a588acf
clippy 2022-12-15 08:49:44 -08:00
Brendan Hansknecht
4571b5b805
some minor cleanup 2022-12-15 08:39:33 -08:00
Brendan Hansknecht
a0622d57a2
ignore stderr print. They are warnings. 2022-12-15 08:29:10 -08:00
Brendan Hansknecht
5ea5208070
also remove unnecessary command from debug path 2022-12-15 08:29:10 -08:00
Brendan Hansknecht
ed002ca68a
add a feature flag and environment variable to enable santizers and fuzzing 2022-12-15 08:29:10 -08:00
Ayaz
f7686e5155
Merge pull request #4754 from roc-lang/i4733
Properly handle imported top levels that appear in a non-unary lambda set
2022-12-15 08:04:07 -06:00
Brendan Hansknecht
1164fb4767
ignore fixup chains 2022-12-14 20:31:56 -08:00
Brendan Hansknecht
1b92a24577
avoid building platform for link type dylib and no link
Both of these cases do not tie to a platform. The roc app can be built without considering the platform.
It is often the case that the platform is using one of these options because roc cannot build the platform.
This allows for more flexibility and avoids wasting time compiling the platform.
2022-12-14 17:34:07 -08:00
Ayaz Hafiz
5606e2d61e
Update test 2022-12-14 17:15:51 -06:00
Ayaz Hafiz
c327189ab7
Remove unneeded whitespace 2022-12-14 17:14:44 -06:00
Ayaz Hafiz
70c27943fa
Toss out unneeded test 2022-12-14 17:14:20 -06:00
Ayaz Hafiz
4315a36e90
Refine imported ZAT/function compilation 2022-12-14 17:13:59 -06:00
Ayaz Hafiz
02eec1f60c
Simplify the model of handling imported/unloaded symbol specializations 2022-12-14 17:13:58 -06:00
Ayaz Hafiz
f08d9c9173
Add gen test for other #4733 reproducer 2022-12-14 17:13:58 -06:00
Ayaz Hafiz
0a071e2a98
Rename mono test 2022-12-14 17:13:58 -06:00
Ayaz Hafiz
1727a9a123
Add gen test for #4733 2022-12-14 17:13:44 -06:00
Ayaz Hafiz
b8aa8df100
Make sure to resolve lambda sets for imported top-levels correctly
Part of #4733
2022-12-14 17:13:43 -06:00
Ayaz Hafiz
ed4e047ee8
Reproduce #4733 2022-12-14 17:12:03 -06:00
Ayaz Hafiz
bd06714fd2
Make sure to constrain dbgs with existential correctly 2022-12-14 17:02:29 -06:00
Ayaz Hafiz
2dc19207a3
Throw away usage of stored variables on receiver side 2022-12-14 17:00:37 -06:00
Ayaz Hafiz
a96225e92e
Store specialized variable for use in dbg as fake symbol in lowlevel call 2022-12-14 17:00:37 -06:00
Ayaz Hafiz
fe90355265
Store specialized variables of expect lookups in expect frames 2022-12-14 17:00:36 -06:00
Ayaz Hafiz
16209ef866
Store specialized lookup variables in expects 2022-12-14 16:59:05 -06:00
Ayaz Hafiz
9d5f2aa138
Store specialized var of lookups in storage subs 2022-12-14 16:55:14 -06:00
Ayaz Hafiz
66c5e1292e
Thread expectations through in phase result structs
And provide expectation subs when expectations should be compiled. This
will be useful for getting the specialized type of an expect lookup when
it's available.
2022-12-14 16:55:14 -06:00
Folkert
d287eafa3a
remove F128 2022-12-14 23:28:38 +01:00
Folkert de Vries
6f2e14cf18
Merge pull request #4765 from roc-lang/expects-store-layout-in-lookaside
Remove layouts from the mono AST for expects, and add regtest for #4749
2022-12-14 23:22:03 +01:00
Ayaz
9b4e30a903
Merge pull request #4745 from roc-lang/i4712
Ensure that disjoint nested lambda sets force parents to be disjoint
2022-12-14 14:55:25 -06:00
Ayaz Hafiz
cec6da19de
Check in mono test 2022-12-14 14:20:10 -06:00
Ayaz Hafiz
1233317907
Add test that #4749 compiles
Now that mono does not store expect lookup layouts, the layout cache
should be primed only when specializing the condition of an expect, and
so #4749 is resolved.

Closes #4749
2022-12-14 14:16:59 -06:00
Ayaz Hafiz
a5ecded934
Don't collect layouts in mono of expects anymore 2022-12-14 14:12:57 -06:00
Ayaz Hafiz
1962f2045e
Remove layouts from the mono AST for expects
This actually isn't needed, because the backends must lookup the layout
from the environment anyway. So it's enough to lookup the symbol and
find its layout, there is no need to additionally store it.
2022-12-14 14:10:02 -06:00
Ayaz Hafiz
f2ffda6d05
Revert "Add a LayoutBuffer to store layouts aside and thread it through"
This reverts commit 3d73e33b49.
2022-12-14 14:05:56 -06:00
Ayaz Hafiz
897b69b072
Revert "Store layouts in a layout-buffer for expects"
This reverts commit bba6e36a18.
2022-12-14 14:05:46 -06:00
Ayaz Hafiz
bba6e36a18
Store layouts in a layout-buffer for expects 2022-12-14 14:05:28 -06:00
Ayaz Hafiz
3d73e33b49
Add a LayoutBuffer to store layouts aside and thread it through 2022-12-14 13:48:58 -06:00
J.Teeuwissen
e3dcaa2141
typo 2022-12-14 14:02:09 +01:00
Brian Carroll
f55fbaad12
builtins: use roc_wasm_interp for Zig wasm tests 2022-12-14 12:09:31 +00:00
Brian Carroll
01d0c5fabc
Merge branch 'main' of github.com:roc-lang/roc into wasm_interp_test_gen 2022-12-14 11:15:42 +00:00
Brian Carroll
c7fe787284
test_gen: ignore eq_linked_list_long as it's quite slow 2022-12-14 08:42:14 +00:00
Brian Carroll
b80278fe48
test_gen: create a debug flag to print wasm interpreter log 2022-12-14 08:42:01 +00:00
Brian Carroll
6cc270241e
test_gen: fix type annotation on character_literal tests 2022-12-14 08:42:01 +00:00
Brian Carroll
c85fd96ef6
test_gen: refcount tests working with wasm_interp 2022-12-14 08:42:01 +00:00
Brian Carroll
adc213b364
test_gen: reorder import names in wasm_linking test 2022-12-14 08:42:01 +00:00
Brian Carroll
9fef0c319f
test_gen: pass Wasm linking test without DCE 2022-12-14 08:42:01 +00:00
Brian Carroll
eaf2782bbd
test_gen: refactor wasm_linking execute_wasm_bytes->execute_wasm_module 2022-12-14 08:42:01 +00:00
Brian Carroll
c8b0e91f3c
test_gen: refactor wasm_linking tests to share more code 2022-12-14 08:42:01 +00:00
Brian Carroll
b4c0ac14c8
gen_wasm: comment about debug env var 2022-12-14 08:42:01 +00:00
Brian Carroll
74bb8cc843
gen_wasm: fix type error in i64 shift operators 2022-12-14 08:42:01 +00:00
Ayaz Hafiz
63b0eb49d8
Explicit is_inside_lambda_set not needed 2022-12-13 09:00:46 -06:00
Richard Feldman
3e5b62db1a
Move exposes into HeaderType 2022-12-13 06:59:25 -05:00
Richard Feldman
7512a964f7
Add HeaderType::Package 2022-12-13 06:44:02 -05:00
Richard Feldman
51c919993a
Load the app msg first 2022-12-13 06:37:23 -05:00
Richard Feldman
d022c19f5c
Merge remote-tracking branch 'origin/main' into packages 2022-12-13 06:04:43 -05:00
Richard Feldman
3d1cdf1fd4
Merge pull request #4737 from roc-lang/to
Use app module's `to` to determine platform
2022-12-13 06:04:25 -05:00
Ayaz Hafiz
79ee266f66
Snapshot/restore pool if lambda sets are disjoint 2022-12-12 18:06:50 -06:00
Richard Feldman
4de0c831bd
Merge pull request #4716 from roc-lang/fuzzing-take-1
Give parser fuzzing some TLC
2022-12-12 18:56:11 -05:00
Ayaz Hafiz
0ef0638862
Remove more dead code 2022-12-12 15:48:30 -06:00
Ayaz Hafiz
22c8719eed
Dead code 2022-12-12 15:47:58 -06:00
Ayaz Hafiz
23932137ef
Avoid exponential unification paths
🤦 when we check whether lambdas can be unified or must be
treated as disjoint we previously had a code path that is actually
exponential in its runtime, regardless of whether it succeeds or fails.
Now, it is linear, though degraded (with a clone) if it fails.
2022-12-12 15:46:05 -06:00
Ayaz Hafiz
1e120653ff
Update derive tests 2022-12-12 15:06:32 -06:00
Ayaz Hafiz
6de816a9fc
Fix test_derive script 2022-12-12 15:04:54 -06:00
Ayaz Hafiz
1262198f7a
Add gen test for #4712 2022-12-12 14:58:41 -06:00
Ayaz Hafiz
cd2b936a59
Ensure that disjoint nested lambda sets force parents to be disjoint
We must be careful to ensure that if unifying nested lambda sets
results in disjoint lambdas, that the parent lambda sets are
ultimately treated disjointly as well.
Consider

```
  v1: {} -[ foo ({} -[ bar Str ]-> {}) ]-> {}
~ v2: {} -[ foo ({} -[ bar U64 ]-> {}) ]-> {}
```

When considering unification of the nested sets

```
  [ bar Str ]
~ [ bar U64 ]
```

we should not unify these sets, even disjointly, because that would
ultimately lead us to unifying

```
v1 ~ v2
=> {} -[ foo ({} -[ bar Str, bar U64 ]-> {}) ] -> {}
```

which is quite wrong - we do not have a lambda `foo` that captures
either `bar captures: Str` or `bar captures: U64`, we have two
different lambdas `foo` that capture different `bars`. The target
unification is

```
v1 ~ v2
=> {} -[ foo ({} -[ bar Str ]-> {}),
         foo ({} -[ bar U64 ]-> {}) ] -> {}
```

Closes #4712
2022-12-12 14:51:18 -06:00
Ayaz Hafiz
f178a86f99
Support pretty-printing can decls in solve tests 2022-12-12 14:50:14 -06:00
Ayaz Hafiz
27dfe974df
Only print lambda ident names in types if they are ambiguous 2022-12-12 14:48:09 -06:00
Ayaz Hafiz
50992d35aa
Support printing lambda names in print decls 2022-12-12 14:13:32 -06:00
Ayaz Hafiz
00ff6dcad7
Print similar-layout procs when borrow fails to find one 2022-12-12 14:13:07 -06:00
Ayaz Hafiz
4cdb8c0cd7
Remove unused unification mismatches 2022-12-12 13:17:43 -06:00
Brendan Hansknecht
662eb5895e
Merge pull request #4741 from roc-lang/ignore-dlclose-errors
remove explicit closing of dylib when testing
2022-12-12 19:14:41 +00:00
Folkert de Vries
c5df39daf4
Merge pull request #4735 from nfreesto/fmt-fix
Fix for #4585
2022-12-12 19:34:21 +01:00
Brendan Hansknecht
dbca7e0f2b
remove explicit closing of dylib when testing 2022-12-12 08:44:56 -08:00
Ayaz Hafiz
04e1e0cd6e
Support better printing of symbols 2022-12-12 10:38:53 -06:00
Ayaz Hafiz
3a2cd2f7c8
Pretty-print canonicalized declarations 2022-12-12 10:28:23 -06:00
Ayaz Hafiz
7135df6d2f
Move can AST pretty-printing into roc_can::debug 2022-12-12 10:09:32 -06:00
Richard Feldman
ec9cf4efe2
Merge branch 'to' into packages 2022-12-12 01:15:34 -05:00
Richard Feldman
8a9e152a5b
Rename PackageName to PackagePath 2022-12-12 00:41:55 -05:00
Richard Feldman
16ce22d455
Use app module's to to determine platform 2022-12-12 00:17:43 -05:00
Richard Feldman
483629216f
Use app module's to to determine platform 2022-12-11 22:22:26 -05:00
Nathan Freestone
04c9454c20
changed expected output for tests to reflect new behavior 2022-12-11 18:39:14 -07:00
Nathan Freestone
83f4cdfaeb
fix for format behavior for multi-line strings 2022-12-11 18:38:47 -07:00
Joshua Warner
e83cd8f191
Re-improve perf of skipping spaces and comments
On my M1 mac this shows as ~25% faster at parsing Num.roc than the old implementation, probably because nobody wrote any NEON code.

Even on my x86_64 linux box (Ryzen 2700x), this shows as 10% faster than the current SSE implementation (running with RUSTFLAGS="-C target-cpu=native").
2022-12-11 08:43:22 -08:00
Joshua Warner
5f29402297
Give parser fuzzing some TLC
* The header + expr fuzzers can both be run again (header fuzzer had regressed).
* I ran the expr fuzzer for ~60 seconds with no additional panics uncovered
* "tab_crash" hit supposedly unreachable code in blankspace.rs - and I went to the liberty of dramatically simplifying all that code, rather than just trying to fix the bug
* Other failures were straight-forward error cases that should have been handled (and passed up the chain) instead of panicking
2022-12-11 08:39:52 -08:00
Richard Feldman
7bf8eb7711
Remove Default::default (makes infinite recursion) 2022-12-11 06:17:32 -05:00
Richard Feldman
3227f95d45
Merge branch 'refactor-platform-info' into packages 2022-12-11 06:17:29 -05:00
Richard Feldman
1cd0097c23
Fix test_gen test 2022-12-11 06:16:29 -05:00
Richard Feldman
f6f8c2876f
Merge remote-tracking branch 'origin/main' into refactor-platform-info 2022-12-11 03:37:48 -05:00
Richard Feldman
141010e6c7
Actually set symbols_from_requires 2022-12-11 03:29:06 -05:00
Richard Feldman
cbc095aa1e
Drop inaccurate comment (copy/paste error) 2022-12-11 03:12:45 -05:00
Richard Feldman
e47898dfff
Rename some more header_for to header_type 2022-12-11 03:02:20 -05:00
Joshua Warner
521afce1f4
Merge pull request #4730 from joshuawarner32/fix-parse-benchmark
Fix parse benchmark and add a benchmark for parsing Num.roc
2022-12-10 16:37:00 -08:00
Joshua Warner
d52b35c1ff
Fix parse benchmark and add a benchmark for parsing Num.roc, the largest builtin file 2022-12-10 11:14:17 -08:00
Richard Feldman
68e6bfcd2a
clippy 2022-12-10 01:49:18 -05:00
Richard Feldman
66f393e30a
Fix a mistake from merge of main 2022-12-10 01:48:38 -05:00
Richard Feldman
75891f6755
fixup! Merge remote-tracking branch 'origin/main' into refactor-platform-info 2022-12-10 01:45:31 -05:00
Richard Feldman
222e0193a3
Don't give packages names 2022-12-10 01:43:53 -05:00
Richard Feldman
e3687935a3
Merge remote-tracking branch 'origin/main' into refactor-platform-info 2022-12-09 22:21:25 -05:00
Richard Feldman
63e9f5da8c
Go back to old opt_main_for_host 2022-12-09 22:18:52 -05:00
Richard Feldman
f34a558c41
Merge pull request #4659 from roc-lang/expect-print-values
Expect print values
2022-12-09 21:24:28 -05:00
Brian Carroll
deab384d02
test_gen: u64 is not always the same size as a pointer, guys, jeez 2022-12-10 00:52:23 +00:00
Brian Carroll
90449f45f3
test_gen: get some tests working with roc_wasm_interp 2022-12-10 00:52:23 +00:00
Brian Carroll
8c7d9dbff8
wasm_interp: Make ValueStack a dumb Vec<Value> => Zig test 146.3->124.6ms 2022-12-09 23:20:50 +00:00
Richard Feldman
bff3204727
Include platform provides in exposed 2022-12-09 16:56:00 -05:00
Richard Feldman
ccb6a98f8a
Address unused arg warning 2022-12-09 14:19:26 -05:00
Richard Feldman
29182d8292
Move platform_main_type into provides 2022-12-09 14:19:07 -05:00
Folkert
1ef27b4bec
fix gen-dev compilation 2022-12-09 18:28:14 +01:00
Folkert
0260182fb4
clippy 2022-12-09 16:03:12 +01:00
Folkert
30ce1ad4bb
cleanup 2022-12-09 15:57:50 +01:00
Folkert
19aa3ade45
fix morphic spec for expect runs in --optimize mode 2022-12-09 15:53:53 +01:00
Folkert
a72556b927
refactor entry point 2022-12-09 15:10:25 +01:00
Richard Feldman
4583985f33
Use a better List.range example for step 2022-12-09 09:08:38 -05:00
Richard Feldman
7d8b9b2323
Fix List.range type annotation bug 2022-12-09 06:53:10 -05:00
Folkert de Vries
234f9f54cd
Merge pull request #4714 from roc-lang/expect-dbg-atomics
use atomics for expect/dbg
2022-12-09 09:21:13 +01:00
Folkert
4b9e64fd7d
Merge branch 'expect-dbg-atomics' into expect-print-values 2022-12-08 23:43:11 +01:00
Folkert
13d0b75bc1
Merge remote-tracking branch 'origin/main' into expect-print-values 2022-12-08 23:42:03 +01:00
Folkert
95fe9cbccd
pass the pointer to shared memory around, instead of using a global 2022-12-08 23:22:26 +01:00
Richard Feldman
97332e4af1
Move ModuleNameEnum into HeaderType 2022-12-08 15:31:43 -05:00
Richard Feldman
e2137cc310
Use a pattern match over an inline let 2022-12-08 15:31:42 -05:00
Richard Feldman
e857a91b1b
Drop obsolete constant 2022-12-08 15:31:42 -05:00
Richard Feldman
8b463686bc
Propagate multiple entrypoints to alias analysis 2022-12-08 15:31:42 -05:00
Richard Feldman
236cebacc1
Refactor out PlatformHeaderInfo 2022-12-08 15:31:42 -05:00
Richard Feldman
2a38edf784
Inline send_header_two 2022-12-08 15:31:42 -05:00
Richard Feldman
87c8702c89
Rename HeaderFor to HeaderType 2022-12-08 15:31:42 -05:00