roc/compiler/gen_wasm/src
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
..
wasm_module Move macros from roc_reporting to new roc_error_macros module 2022-01-23 18:40:04 +01:00
backend.rs Hash record field name order in generated layouts 2022-02-21 14:10:45 -05:00
layout.rs Hash record field name order in generated layouts 2022-02-21 14:10:45 -05:00
lib.rs wasm: get rid of Result from gen_wasm, rename a function, improve comments 2022-02-08 11:03:48 +00:00
low_level.rs Hash record field name order in generated layouts 2022-02-21 14:10:45 -05:00
storage.rs Move macros from roc_reporting to new roc_error_macros module 2022-01-23 18:40:04 +01:00
wasm32_result.rs repl: continue fleshing out the Wasm repl code. Generate wrapper function. 2022-02-08 11:03:48 +00:00
wasm32_sized.rs repl: move wasm32_test_result to gen_wasm, and extract Wasm32Sized from FromWasm32Memory 2022-02-08 11:03:48 +00:00