Commit graph

7453 commits

Author SHA1 Message Date
ayazhafiz
475be2363c Add a gen test for #2535 2022-02-21 14:10:46 -05:00
ayazhafiz
dfc384aa1f Make mono test output prettier 2022-02-21 14:10:45 -05:00
ayazhafiz
e52d427ac8 Hash record field name order in generated layouts
Closes #2535

See the referenced issue for longer discussion - here's the synopsis.
Consider this program

```
app "test" provides [ nums ] to "./platform"

alpha = { a: 1, b: 2 }

nums : List U8
nums =
    [
        alpha.a,
        alpha.b,
    ]
```

Here's its IR:

```
procedure : `#UserApp.alpha` {I64, U8}
procedure = `#UserApp.alpha` ():
    let `#UserApp.5` : Builtin(Int(I64)) = 1i64;
    let `#UserApp.6` : Builtin(Int(U8)) = 2i64;
    let `#UserApp.4` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = Struct {`#UserApp.5`, `#UserApp.6`};
    ret `#UserApp.4`;

procedure : `#UserApp.nums` List U8
procedure = `#UserApp.nums` ():
    let `#UserApp.7` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.1` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.7`;
    let `#UserApp.3` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.2` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.3`;
    let `#UserApp.0` : Builtin(List(Builtin(Int(U8)))) = Array [`#UserApp.1`, `#UserApp.2`];
    ret `#UserApp.0`;
```

What's happening is that we need to specialize `alpha` twice - once for the
type of a narrowed to a U8, another time for the type of b narrowed to a U8.

We do the specialization for alpha.b first - record fields are sorted by
layout, so we generate a record of type {i64, u8}. But then we go to
specialize alpha.a, but this has the same layout - {i64, u8} - so we reuse
the existing one! So (at least for records), we need to include record field
order associated with the sorted layout fields, so that we don't reuse
monomorphizations like this incorrectly!
2022-02-21 14:10:45 -05:00
Brendan Hansknecht
74daec84df
Merge pull request #2472 from rtfeldman/add_Int.toInt_builtins
Add `{Int *}.to{Int *}` builtins
2022-02-21 18:03:14 +00:00
Anton-4
985af24071
added reference to created issue for update_key 2022-02-21 17:20:19 +01:00
ayazhafiz
e22c9d8168 Fix a typo 2022-02-21 10:29:24 -05:00
Emi Simpson
ff0c994668
Improve library lookup in native linker
🐛 Fix bug where /usr/lib isn't checked if /usr/lib/{arch} exists
 Better error messages on missing libraries
 Check /usr/lib64 for libraries
2022-02-21 10:18:23 -05:00
Brian Carroll
e8571de1ae
Merge pull request #2517 from rtfeldman/repl-www
Web REPL initial version
2022-02-21 13:58:23 +00:00
Anton-4
48d5775f62
simplification, stricter adherence to projectional editing approach 2022-02-21 14:47:57 +01:00
ayazhafiz
543ca97a1c Remove spaces around var in record update
Closes #2534
2022-02-20 20:17:29 -05:00
ayazhafiz
6b53692aac Canonicalize opaque types 2022-02-20 13:47:01 -05:00
Brian Carroll
603c98d1d9 wasm tests: use wasmer .unwrap_i32 2022-02-20 09:05:08 +00:00
Brendan Hansknecht
2154e910d8 expand test coverage 2022-02-19 19:39:44 -08:00
Brendan Hansknecht
c6f1edbf47 load literals that are union args 2022-02-19 19:24:37 -08:00
Brendan Hansknecht
28ec18c564 add new union creation 2022-02-19 19:14:09 -08:00
ayazhafiz
6104a27b45 Parse opaque references 2022-02-19 21:30:42 -05:00
ayazhafiz
a38f1d1e8d Fmt and clippy 2022-02-19 20:54:21 -05:00
ayazhafiz
3c10ad2a9f Test for opaque definitions 2022-02-19 20:51:12 -05:00
Brendan Hansknecht
f8e12da809 add List.getUnsafe 2022-02-19 17:07:53 -08:00
Brendan Hansknecht
c47209c54a add copying any memcpy-able symbols to a stack offset 2022-02-19 16:48:27 -08:00
Brendan Hansknecht
1ef7df19b4 add List.set 2022-02-19 16:43:24 -08:00
Brendan Hansknecht
4bc59cdb61 add storing large args for passing 2022-02-19 16:42:21 -08:00
Brendan Hansknecht
b5a10695ac update ret pointer returning 2022-02-19 16:36:28 -08:00
Brendan Hansknecht
cf8d294ec1 add List.len 2022-02-19 16:01:59 -08:00
Brendan Hansknecht
a39f610395 add copying to a return pointer 2022-02-19 15:53:31 -08:00
ayazhafiz
fa24e51593 Parse opaque types 2022-02-19 18:38:31 -05:00
Brendan Hansknecht
39b9ab44a7 more ignoring of branch info 2022-02-19 15:34:27 -08:00
Brendan Hansknecht
bbee753e21 copying list and str to stack offset 2022-02-19 15:33:39 -08:00
Brendan Hansknecht
c0b0fe3ba1 add Num.Lte 2022-02-19 15:29:52 -08:00
Brian Carroll
a75aa52b91 repl_test: write Rust replacements for JS functions 2022-02-19 23:29:06 +00:00
Brendan Hansknecht
f2e5b63ec3 load union at index for recursive and nonrecursive unions 2022-02-19 15:24:25 -08:00
Brendan Hansknecht
a86f1193c6 skip branch info in switch 2022-02-19 15:15:08 -08:00
Brendan Hansknecht
bed779a290 add zero and sign extension 2022-02-19 15:12:50 -08:00
ayazhafiz
8ce81e4607 AliasHeader -> TypeHeader 2022-02-19 17:51:56 -05:00
Brendan Hansknecht
f55f82119c wider int support for equality 2022-02-19 14:16:06 -08:00
Brendan Hansknecht
2307be8f0a add loading tag for non-recursive union 2022-02-19 14:09:55 -08:00
ayazhafiz
ee37d8c4e0 Disable unimplemented int casts on wasm 2022-02-19 17:08:20 -05:00
ayazhafiz
aa8b6e3393 Clippy 2022-02-19 16:28:36 -05:00
ayazhafiz
25b355eb38 Fix cast tests 2022-02-19 16:24:49 -05:00
Brendan Hansknecht
05959b0622 enable returning small complex types 2022-02-19 13:23:13 -08:00
ayazhafiz
13067f2908 Implement Num.toNNNChecked
Closes #2411
2022-02-19 16:20:21 -05:00
Brendan Hansknecht
582413a5bb add List.get wrapper 2022-02-19 13:18:17 -08:00
Brendan Hansknecht
dcc68fbc84 enable passing lists to functions 2022-02-19 13:15:51 -08:00
Folkert de Vries
1b664741db
Merge pull request #2528 from rtfeldman/roc-std-list-str-refactor
Roc std list str refactor
2022-02-19 21:53:19 +01:00
Brian Carroll
718f0a85c6
Merge pull request #2524 from rtfeldman/gen-dev/cleanup
Gen dev/cleanup
2022-02-19 19:34:38 +00:00
Brendan Hansknecht
0dae9014fe Update comments 2022-02-19 10:59:32 -08:00
ayazhafiz
d90915a8cd Implement Num.to* builtins
Just wrap over Num.intCast
2022-02-19 11:28:41 -05:00
Jan Van Bruggen
e12d98af98 WIP: Start adding new Int.toInt builtins 2022-02-19 11:28:12 -05:00
Jan Van Bruggen
1760db2a0c Add docs for new Int.toInt builtins 2022-02-19 11:28:12 -05:00
Folkert
637360fad5
clippy 2022-02-19 16:50:42 +01:00