Commit Graph

21 Commits

Author SHA1 Message Date
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
Folkert
957140df64 remove builtin lookup function being passed around 2022-02-14 20:32:31 +01:00
Brian Carroll
3c6cb5bc19 repl: Separate traits for the app and its memory 2022-02-08 11:03:48 +00:00
Brian Carroll
1528651a5a repl: explicit lifetimes for app 2022-02-08 11:03:48 +00:00
Brian Carroll
fdf8363b7e repl: Separate app from env 2022-02-08 11:03:48 +00:00
ayazhafiz
364d2585df Fix repl tests 2022-02-06 15:04:12 -05:00
Brian Carroll
8df69d856c repl: update a comment 2022-02-03 12:08:32 +00:00
Brian Carroll
5904bb05ad repl: remove unused dependencies from roc_repl_eval 2022-02-03 09:30:04 +00:00
Brian Carroll
eb1a16d429 repl: fix tests 2022-02-03 00:27:33 +00:00
Brian Carroll
b317e05187 repl: formatting and Clippy 2022-02-03 00:02:12 +00:00
Brian Carroll
9ace2fd9a3 repl: delete app_memory and put "external memory" logic into repl_wasm 2022-02-02 23:08:12 +00:00
Brian Carroll
fdea13ac55 repl: thread the ReplApp through the evaluator 2022-02-02 22:54:18 +00:00
Brian Carroll
380c24ba80 repl: move LLVM specific logic into roc_repl_cli 2022-02-02 22:32:12 +00:00
Brian Carroll
e8ab649f73 repl: remove redundant str <-> &[u8] conversions on input source code 2022-02-02 21:57:42 +00:00
Brian Carroll
881e43336c repl: rename jit function for dynamic size and change its doc comment 2022-02-02 21:36:28 +00:00
Brian Carroll
87886e2e6b repl: implement string evaluation for 32-bit platforms 2022-02-02 15:23:47 +00:00
Brian Carroll
4994b0ef1b repl: replace LLVM jit macros with functions 2022-02-02 15:06:04 +00:00
Brian Carroll
ad4318f1ff Merge branch 'trunk' of github.com:rtfeldman/roc into repl-packages 2022-02-01 11:16:37 +00:00
Brian Carroll
bbe82fcf25 repl: refactor LLVM-specific code under an optional Cargo feature 2022-02-01 11:15:37 +00:00
Brian Carroll
516b3ee296 repl: Delete unused debug file 2022-01-31 06:50:08 +00:00
Brian Carroll
f098c6cb99 repl: initial working version with new crate structure 2022-01-30 09:12:29 +00:00