Commit graph

822 commits

Author SHA1 Message Date
Folkert de Vries
249878cbd9
Merge pull request #2281 from rtfeldman/i/2149
(llvm) Generate code for tag unions less than 64 bits in size correctly
2021-12-27 22:38:08 +01:00
ayazhafiz
5e5eb6dca8 (llvm) Generate code for tag unions less than 64 bits in size correctly
Previously, we assumed that a union layout always lived on >= 1 64-bit
boundary when generating an LLVM type for it. For small tags unions,
like `[ Ok i8, Err ]` this need not be the case; indeed, a tag union
like that is actually only 2 bits - 1 bit for the "i8" data, and one bit
of the tag kind.

This led to a discrepancy between what the layout IR and generated LLVM
code would assume about the size of tag unions. In the case above, the
layout IR would assume the tag data is 2 bits wide, and the tag id is 1
bit into the data. But the LLVM code would generate a type that was 65
bits wide, the first 64 bits being for the "i8" data and the last 1 bit
being for the tag kind.

Usually, just running the LLVM-emitted code would not present a problem.
But it does present a problem when we use the layout IR to inspect the
result of LLVM-run code, in particular when we try to look up the tag
ID, as the repl does. This patch fixes that issue.

Note that this bug did not present itself in `test_gen` previously
because the data that most tests check against is stored in the front of
the representation.

Closes #2149
2021-12-26 11:45:02 -06:00
ayazhafiz
966198a6e7 Coalesce inline and normal alias headers
Unifies `As` annotations and `Alias` defs to use a common struct for
defining alias header information, i.e. the name and type variables of
the alias.
2021-12-26 09:37:56 -06:00
ayazhafiz
2cd5bf8c03 Parse "as" aliases into tag/args rather than arbitrary annotations 2021-12-26 08:44:09 -06:00
Joshua Warner
8b58d5cbc7 Switch to always encoding package names / paths as strings
This will simplify parsing and make it possible to have a uniform lexer for the language. Previously unquoted package names were allowed to include '-'s, which aren't valid identifiers.

In the future, we'll distinguish local paths from packages in the package-manager by looking for a ".roc" suffix, which should only be present in local paths.
2021-12-23 20:11:14 -08:00
Joshua Warner
4d7070ce3b Always combine line,column into Position 2021-12-22 20:32:46 -08:00
Joshua Warner
f19220473a Rename Located -> Loc 2021-12-22 19:18:22 -08:00
Joshua Warner
49818343dd extract state 2021-12-16 17:13:53 -08:00
Joshua Warner
0786e554c6 Extract spacing from parse::header::* items into explicit Spaced enum 2021-12-14 19:53:20 -08:00
Jan Van Bruggen
d03a51c75b Rename base package to pf everywhere, to match tutorial 2021-12-12 05:57:39 -07:00
Folkert
cea1336518 needed an indent in repl 2021-12-05 15:44:12 +01:00
Folkert
009d1c8163 variable did not need to be mut 2021-12-05 15:11:52 +01:00
Folkert
4af9539ce6 fixes by cargo clippy --fix 2021-12-05 15:04:28 +01:00
Joshua Warner
e3f2f8d9a4 keep indent state in fmt Buf 2021-12-04 18:26:32 -08:00
Joshua Warner
270cc49867 Also check formatting is stable in tests; ignore a test that's invalid / incorrect 2021-12-02 17:46:50 -08:00
Joshua Warner
595ce5e81a Check that formatting is stable before writing the result to a file 2021-12-02 17:17:56 -08:00
Matthias Devlamynck
1be01a85e7 Remove unnecessary unwraps in CLIs by using subcommand() 2021-12-02 09:33:48 +01:00
Richard Feldman
f80409800d
Merge pull request #2091 from rtfeldman/remove-empty-layouts
Remove empty layouts
2021-11-27 23:32:15 -05:00
Folkert de Vries
efe07ea4e1
Merge pull request #2090 from rtfeldman/joshuawarner32/fix-remove-spaces-oversights
Fix a few places non-0 Located slipped by RemoveSpaces
2021-11-27 16:48:53 +01:00
Joshua Warner
54317f4c0c Fix a few places non-0 Located slipped by RemoveSpaces 2021-11-27 07:15:05 -08:00
Folkert
a1fd34feef remove empty layout types (list,str,dict,set) 2021-11-27 14:05:16 +01:00
Joshua Warner
16cf95cf6e Improve formatting of formatter error messages, and also write out the invalidly formatted file separately 2021-11-26 17:18:11 -08:00
Joshua Warner
2547c2ef47 Add comment 2021-11-26 14:03:49 -08:00
Joshua Warner
08c1317cf8 Verify ast matches before/after formatting 2021-11-26 14:00:36 -08:00
Folkert
612f868652 make VariableSubsSlice an alias 2021-11-25 20:29:34 +01:00
Joshua Warner
c5388ba3ad use std::env::current_dir 2021-11-22 20:45:12 -08:00
Joshua Warner
3f8c6be9e9 Implement 'roc format <dir_or_files>' command 2021-11-22 18:00:25 -08:00
Folkert
dc44eaac97 cleanup 2021-11-21 14:11:18 +01:00
Folkert
073d5205ca fix repl bug 2021-11-21 02:16:57 +01:00
Folkert
406974824b fix repl 2021-11-21 00:55:05 +01:00
Folkert
c4ec9aa898 working mono 2021-11-20 23:25:30 +01:00
Folkert de Vries
71233fcfc1
Merge pull request #2012 from rtfeldman/i/1714
Take syntactic sugar into account when reporting errors
2021-11-19 10:26:24 +01:00
Richard Feldman
f61f19d817
Merge pull request #1989 from rtfeldman/enhancement/1814
WIP: Print rebuild logs when rebuilding the host
2021-11-18 22:30:34 -05:00
ayazhafiz
8b7217847d Rename additional stale roc_module::operator refs and format 2021-11-18 20:20:33 -05:00
ayazhafiz
8a60162a1e Rename roc_module::operator -> roc_module::called_via
A bit of a nit, but this file is now more general than just keeping
track of operator methods.
2021-11-18 20:20:33 -05:00
Callum Dunster
f972098e70 Move reporting module into root. 2021-11-16 19:58:21 +01:00
Cristiano Piemontese
1feab3651c add host rebuild info logs 2021-11-16 12:43:22 +01:00
Anton-4
0f064c121e
Merge branch 'trunk' into valgrind_instr_fix 2021-11-16 12:24:26 +01:00
Richard Feldman
28273b67da
Merge pull request #1970 from rtfeldman/shrink-call-type
Shrink call type
2021-11-15 19:56:21 -08:00
Anton-4
7330e3b11a clippy fix 2021-11-15 15:12:37 +01:00
Anton-4
6e23919811 put mcpu in comments 2021-11-15 13:43:19 +01:00
Folkert de Vries
066487ea6e
Merge branch 'trunk' into joshuawarner32/use-collection-4 2021-11-14 13:31:46 +01:00
Folkert
fcb89cbcd8 Merge remote-tracking branch 'origin/trunk' into shrink-call-type 2021-11-13 19:31:30 +01:00
Joshua Warner
d63405d824 Make Expr::List use a Collection 2021-11-13 07:38:11 -08:00
Joshua Warner
a4ca6a31a6 Use Collection in Expr::Record and related places 2021-11-13 07:36:05 -08:00
Folkert
d18c09a21d misc other clippy things 2021-11-13 16:04:50 +01:00
Anton-4
030a504bd2 valgrind flag 2021-11-13 14:39:15 +01:00
Folkert
38da99b1ac make it work 2021-11-11 23:36:35 +01:00
Folkert
c827256e47 Merge remote-tracking branch 'origin/trunk' into tag-union-imitate-rust 2021-11-11 18:58:49 +01:00
Richard Feldman
f82ca36b19
Merge pull request #1939 from rtfeldman/cli_improvements
cli improvements, added examples to nightly release
2021-11-11 00:21:56 +01:00