Commit graph

591 commits

Author SHA1 Message Date
Folkert
d1d7cfef44
reimplement Result 2022-02-23 17:52:13 +01:00
ayazhafiz
e420ebd023 Add TODOs for opaque type comments that will need to be changed later 2022-02-21 23:21:39 -05:00
ayazhafiz
6b53692aac Canonicalize opaque types 2022-02-20 13:47:01 -05: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
ayazhafiz
fa24e51593 Parse opaque types 2022-02-19 18:38:31 -05:00
ayazhafiz
8ce81e4607 AliasHeader -> TypeHeader 2022-02-19 17:51:56 -05:00
Joshua Warner
f440d53e7b Refactor: introduce trait SpaceProblem to remove a bunch of redundant args in ::Space errors 2022-02-15 20:48:04 -08:00
Jan Van Bruggen
f328ff5661
Remove leading newlines from code files 2022-02-13 14:55:34 -07:00
Jan Van Bruggen
fa466cd8d8
Fix a failing test
How did this pass CI testing?

Output from `cargo test --release`:
```
failures:

---- test_parse::comment_after_def stdout ----
The source code for this test did not successfully parse!

thread 'test_parse::comment_after_def' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
 [
<    |L 0-0, C 0-7| SpaceAfter(
>    @0-7 SpaceAfter(
         SpaceBefore(
             Body(
<                |L 0-0, C 0-3| Identifier(
>                @0-3 Identifier(
                     "foo",
                 ),
<                |L 0-0, C 6-7| Num(
>                @6-7 Num(
                     "1",
                 ),
             ),
             [],
         ),
         [
             LineComment(
                 " comment after",
             ),
         ],
     ),
 ]

', compiler/parse/tests/test_parse.rs:291:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    test_parse::comment_after_def

test result: FAILED. 164 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

error: test failed, to rerun pass '-p roc_parse --test test_parse'
```
2022-02-11 04:20:29 -07:00
Anton-4
d6681f4e0a
Merge pull request #2160 from rtfeldman/editor-comments
support tld comments in docs and editor(reading only)
2022-02-10 11:49:10 +01:00
Folkert
f02db3961a fix parse tests 2022-02-04 22:51:18 +01:00
Folkert
f1ebc523b6 Merge remote-tracking branch 'origin/trunk' into hook-up-hosted-modules 2022-02-04 00:07:23 +01:00
Folkert
885500712c remove old Effect module things 2022-02-03 23:55:02 +01:00
Folkert
a98635ed06 update other examples 2022-02-03 22:45:15 +01:00
Folkert
16a2b660c3 bookkeeping 2022-02-02 23:11:52 +01:00
Folkert
1fb746757c pipe module name into canonicalization of modules 2022-02-02 16:01:31 +01:00
ayazhafiz
a6f7579c07 Parse and expand numeric bounds in canonicalization pass 2022-02-01 22:50:46 -05:00
ayazhafiz
17c5fe0bff Add granular errors regarding numeric literal parsing 2022-02-01 22:50:27 -05:00
ayazhafiz
9f72b2710f Run linter 2022-02-01 22:49:52 -05:00
ayazhafiz
f7a055fc78 Fix parser tests 2022-02-01 22:49:52 -05:00
ayazhafiz
e03592930f Typecheck numeric literals with suffixes in expressions
Part of #2350
2022-02-01 22:49:50 -05:00
ayazhafiz
320827167f Parse number literal width suffixes
Supports [u,i][8,16,32,64,128] and [nat,dec]

Part of #2350
2022-02-01 22:48:48 -05:00
ayazhafiz
4e942b3e5d Make nested datatypes into errors
I was hoping to add nested datatypes into the language, but it turns out
doing so is quite tricky and not all that useful with Roc's current
compilation model. Basically every implementation strategy I could think
of ended up requiring a uniform representation for the data layout
(or some ugly workaround). Furhermore it increased the complexity of the
checker/mono IR generator a little bit - basically, we must always pass
around the alias definitions of nested datatypes and instantiate them
at usage sites, rather than being able to unroll aliases as we currently
do during canonicalization.

So, especially because we don't support polymorphic recursion anyway, I
think it may be better to simply disallow any kind of nested datatypes
in the language. In any case, Stephanie Weirich [seems to think nested
datatypes are not needed](https://www.cis.upenn.edu/~plclub/blog/2020-12-04-nested-datatypes/).

Closes #2293
2022-01-31 22:58:01 -05:00
Richard Feldman
755f4c01f3
cargo fmt 2022-01-30 20:40:51 -05:00
Richard Feldman
2eb9243942
Add parse tests for hosted modules 2022-01-30 20:40:50 -05:00
Richard Feldman
c68dfdf61e
Drop some unused variants 2022-01-30 20:40:49 -05:00
Richard Feldman
484ce2fbc9
Parse hosted modules 2022-01-30 20:40:49 -05:00
ayazhafiz
b50bb9a4c7 Centralize closure type 2022-01-30 00:48:01 -05:00
ayazhafiz
84f8152514 Remove debug_assert that may legally check a false value
This may be false e.g. in the presence of a multiline string. Since the
parser is in a more stable state than when this was introduced, I think
this is OK to remove.

Closes #2398
2022-01-29 23:58:46 -05:00
ayazhafiz
8ae2d9d407 Parse interfaces with leading newlines
Closes #2420
2022-01-29 23:58:41 -05:00
Richard Feldman
4fadc775e8 Add parse tests snapshot 2022-01-23 12:20:35 -05:00
Richard Feldman
1ab621dd54 Support optional spaces in app header types 2022-01-23 12:02:34 -05:00
Richard Feldman
01942fd98e Parse app header provided types 2022-01-23 11:52:59 -05:00
Richard Feldman
c1c0ffb25f Use UppercaseIdent over PlatformRigids 2022-01-23 11:13:23 -05:00
Richard Feldman
620e3f2913 parse tests for provided/required types in module headers 2022-01-23 10:11:17 -05:00
Jan Van Bruggen
fb66467343 Remove trailing spaces from test snapshots 2022-01-18 22:33:24 -07:00
Jan Van Bruggen
1e9d2d1239 Remove accidental trailing spaces 2022-01-18 22:25:46 -07:00
Joshua Warner
6e67b77fa1 Remove awkward split between header_sources and defs sources 2022-01-13 19:34:17 -08:00
Joshua Warner
d9cfa2b2a5 Remove unused State::fail method 2022-01-03 20:11:01 -08:00
Joshua Warner
352c7979eb Re-enable debug_assert in State::advance 2022-01-03 20:10:53 -08:00
Joshua Warner
f22f96843e Refactor ParseProblem
* Remove the `pos` field, which was always being assigned Position::default()
* Remove one use of this `pos`, by removing the never-used SyntaxError::ConditionFailed variant
* Adjust the other use to do what was probably intended - which is to say, pointing to the beginning of the def with the error
* Rename to FileError, reuse `SourceError` as an inner field, to avoid duplicating the `bytes`
2022-01-03 20:10:50 -08:00
Joshua Warner
650c29de3c Change LineColumn::column to u32 to avoid overflow, and remove LineTooLong error 2022-01-02 21:50:42 -08:00
Joshua Warner
9557c234cb Update recently added tests 2022-01-01 18:20:57 -08:00
Joshua Warner
8092f31a29 fmt 2022-01-01 18:20:05 -08:00
Joshua Warner
f969c7c6d0 Fixup rebase errors 2022-01-01 18:20:05 -08:00
Joshua Warner
5c1084c453 Introduce SourceError to represent an error + original source 2022-01-01 18:20:05 -08:00
Joshua Warner
8d6eb178b1 Fix multiline pattern heuristic 2022-01-01 18:20:05 -08:00
Joshua Warner
e97e5c3bd9 Fixup type annotations 2022-01-01 18:20:05 -08:00