Commit graph

1831 commits

Author SHA1 Message Date
ayazhafiz
903fa7d363 Fix clippy warning: implement From over Into 2021-12-21 19:55:50 -06:00
ayazhafiz
e451c3a1f9 Small refactoring: coalesce record field collection loop 2021-12-21 19:23:07 -06:00
ayazhafiz
576f1293fd Turn invalid record field types into runtime errors
By emitting a runtime error rather than panicking when we can't layout
a record, we help programs like

```
main =
    get = \{a} -> a
    get {b: "hello world"}
```

execute as

```
Mismatch in compiler/unify/src/unify.rs Line 1071 Column 13
Trying to unify two flat types that are incompatible: EmptyRecord ~ { 'a' : Demanded(122), }<130>

🔨 Rebuilding host...
── TYPE MISMATCH ───────────────────────────────────────────────────────────────

The 1st argument to get is not what I expect:

8│      get {b: "hello world"}
            ^^^^^^^^^^^^^^^^^^

This argument is a record of type:

    { b : Str }

But get needs the 1st argument to be:

    { a : a }b

Tip: Seems like a record field typo. Maybe a should be b?

Tip: Can more type annotations be added? Type annotations always help
me give more specific messages, and I think they could help a lot in
this case

────────────────────────────────────────────────────────────────────────────────

'+fast-variable-shuffle' is not a recognized feature for this target (ignoring feature)
'+fast-variable-shuffle' is not a recognized feature for this target (ignoring feature)
Done!
Application crashed with message

    Can't create record with improper layout

Shutting down
```

rather than the hanging

```
Mismatch in compiler/unify/src/unify.rs Line 1071 Column 13
Trying to unify two flat types that are incompatible: EmptyRecord ~ { 'a' : Demanded(122), }<130>

thread '<unnamed>' panicked at 'invalid layout from var: UnresolvedTypeVar(104)', compiler/mono/s
rc/layout.rs:1510:52
```

that was previously produced.

Part of #2227
2021-12-21 19:11:59 -06:00
Brian Carroll
d58a2814f6 Generate IR for list equality 2021-12-21 23:14:55 +00:00
Brian Carroll
a2ada314ce local constants for ARG_1 and ARG_2 2021-12-21 23:14:55 +00:00
Brian Carroll
7477b8239d Get rid of some function arguments that are always the same 2021-12-21 23:14:55 +00:00
Brian Carroll
9b833720d4 Further refactor and debug == in Wasm 2021-12-20 08:39:16 +00:00
Brian Carroll
635c9757dd Implement Eq for tags in CodeGenHelp 2021-12-19 21:20:01 +00:00
Brian Carroll
570044f88a Check pointer equality for Eq on Structs 2021-12-19 09:06:06 +00:00
Brian Carroll
e847c924dd Lowlevels: replace RefCountGetPtr with the more general GetPtrAsInt. 2021-12-19 08:29:17 +00:00
Brian Carroll
a1d883600c Equality operator for records 2021-12-18 17:25:00 +00:00
Brian Carroll
55f5956175 Add comments to group code together 2021-12-18 00:23:31 +00:00
Brian Carroll
71bb756d20 Move related code closer together 2021-12-18 00:12:19 +00:00
Brian Carroll
2d887b297f Fill out match expressions in generate_procs 2021-12-18 00:11:18 +00:00
Brian Carroll
0f2d14490f Clippy fixes 2021-12-16 16:58:37 +00:00
Brian Carroll
307ab9ee83 Use a single enum for all helpers 2021-12-16 16:56:56 +00:00
Brian Carroll
3eb9e9f7ac Traverse nested layouts for code gen helpers 2021-12-16 16:56:56 +00:00
Brian Carroll
ae9e5f115f Generate specialized call for Eq 2021-12-16 16:56:56 +00:00
Brian Carroll
e1a04c2661 Only check layout is implemented for RC, not other ops 2021-12-16 16:56:56 +00:00
Brian Carroll
3adaacc66e Add some comments 2021-12-16 16:56:53 +00:00
Brian Carroll
cd91be678f Setup for specializing equality checks 2021-12-16 16:52:47 +00:00
Brian Carroll
ee97eb668d Add Eq operation to code gen helpers 2021-12-16 16:52:47 +00:00
Brian Carroll
efef2be958 Rename mono IR code gen helpers 2021-12-16 16:52:47 +00:00
Brian Carroll
71de2289ae Rename helper proc generator struct 2021-12-16 16:52:47 +00:00
Brian Carroll
0547647341 Rename code gen helper file in mono 2021-12-16 16:52:47 +00:00
Brian Carroll
c290bbe7a7 Move layout calculations to layout module 2021-12-12 12:22:10 +00:00
Brian Carroll
c53b3c3686 Skip refcounting on unimplemented layouts 2021-12-11 20:33:11 +00:00
Brian Carroll
211a5d9bf3 Fix apparent bug in Layout::is_refcounted
It contradicts build_tag in compiler/gen_llvm/src/llvm/build.rs,
where we create a NonNullableUnwrapped by calling
reserve_with_refcount_union_as_block_of_memory
2021-12-11 20:33:11 +00:00
Brian Carroll
031dce61c9 Add a stack_size_and_alignment method to Layout 2021-12-11 20:33:11 +00:00
Brian Carroll
7b6ba79eee Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-tags 2021-12-10 11:48:56 +00:00
Richard Feldman
1ce648ac27
Merge pull request #2116 from rtfeldman/str_to_num
Str.toNum
2021-12-09 09:48:38 -05:00
Brian Carroll
2f4225eec6 Add more doc comments to UnionLayout enum 2021-12-08 20:30:26 +00:00
Brendan Hansknecht
b8a287d1ba Merge remote-tracking branch 'origin/trunk' into refcount-gen-dev 2021-12-08 11:22:36 -08:00
Folkert
28b4388488 remove unneeded field 2021-12-05 15:25:46 +01:00
Folkert
d7045b037f use param_map instead of localcontext 2021-12-05 15:21:25 +01:00
Folkert
eaefb56994 make some helper functions non-mut 2021-12-03 21:50:39 +01:00
Anton-4
c63c69f1ef prep merge with Folkert's branch 2021-12-01 19:42:22 +01:00
Anton-4
eaf4e57759 started on Str.toNum 2021-12-01 15:15:30 +01:00
Richard Feldman
e6bec46898
Merge pull request #2109 from rtfeldman/refactor-passed-function
refactor passed (to higher order lowlevel) funcion
2021-12-01 08:17:39 -05:00
Brian Carroll
a3827d6636
Merge pull request #2071 from rtfeldman/refcount-mono-ir
Start generating refcounting code as mono IR
2021-12-01 12:59:16 +00:00
Folkert
834ba77046 missed a bool 2021-12-01 12:53:47 +01:00
Chelsea Troy
0e5f82526a Account for SingleQuote in the case statements for the cli, plus some errata
+ Evidently I failed to finish fixing merge conflicts
+ Some of the types that the SingleQuote code mentioned didn't exist according to the build step. I looked around and switched them out for types it LOOKED like they were supposed to be, but someone should probably check this
+ Don't make commits like this; it's multiple unrelated changes thrown together. I'm still figuring out my way around here
2021-12-01 00:13:15 -06:00
Folkert
bec74c36c5 refactor passed (to higher order lowlevel) funcion 2021-11-30 21:50:27 +01:00
rvcas
f995a07029 feat: Num.toStr
* add type for Num.toStr
  * create new lowlevel
  * delete types and Symbol for fromInt and fromFloat
  * leave LowLevel::{StrFromFloat,StrFromInt}
  * match on LowLevel::NumToStr and figure out the layout to decide
    which build function to delegate to
2021-11-30 14:52:06 -05:00
Brian Carroll
2bb49f55f8 Doc comment for RefcountProcGenerator 2021-11-30 15:48:35 +00:00
Brian Carroll
1c3b76ba03 Fix a bug in generated refcount proc for str 2021-11-30 12:59:22 +00:00
Brian Carroll
22ccb6eca4 Prefix string constants with REFCOUNT_MAX 2021-11-30 09:57:31 +00:00
Brian Carroll
c2a2ff2957 Create Expr::to_pretty in mono IR 2021-11-30 09:57:26 +00:00
Brian Carroll
3581c7f5be Use readable debug names throughout refcount proc generator 2021-11-30 09:57:00 +00:00
Brian Carroll
820d9e0ab4 Register debug names for new Symbols, and refactor to avoid borrow-checker issues 2021-11-30 09:57:00 +00:00