Commit graph

335 commits

Author SHA1 Message Date
Ayaz Hafiz
3d0a0a4a99
Update more dict/set references 2023-01-14 15:33:54 +01:00
Richard Feldman
ab7de647e4
Merge pull request #4863 from joshuawarner32/better-scalar-literals
Improve parsing of scalar literals
2023-01-09 11:42:44 -05:00
Ayaz
7c61d0d278
Merge pull request #4843 from roc-lang/pattern-as-can
Pattern as can
2023-01-08 19:36:40 -06:00
Folkert
c2ddeb0de0
fix and test as pattern type inference 2023-01-08 16:40:03 +01:00
Joshua Warner
94070e8ba6
Improve parsing of scalar literals
* Unify parsing of string literals and scalar literals, to (e.g.) ensure escapes are handled uniformly. Notably, this makes unicode escapes valid in scalar literals.
* Add a variety of custom error messages about specific failure cases of parsing string/scalar literals. For example, if we're expecting a string (e.g. a package name in the header) and the user tried using single quotes, give a clear message about that.
* Fix formatting of unicode escapes (they previously used {}, now correctly use () to match roc strings)
2023-01-07 15:12:52 -08:00
Ayaz Hafiz
bcfb258db8
Add a bit to mark syntactically-generalizable types 2023-01-04 17:02:20 -06:00
Ayaz Hafiz
3b0e2429e6
Support printing weak type variables in tests
Unbound type variables that are not at the generalization rank will now
be printed as `w_a` in solve tests.
2023-01-04 16:24:19 -06:00
Ayaz
9171799c67
Merge pull request #4841 from roc-lang/parse-pattern-as
Parse pattern as
2022-12-31 13:19:57 -06:00
Folkert
2e27746413
can for list .. as 2022-12-31 16:00:40 +01:00
Folkert
905341d849
can for normal (no-list) as 2022-12-31 15:46:11 +01:00
Richard Feldman
879b957676
Delete unused branch (it never got hit on CI) 2022-12-30 22:40:45 -05:00
Folkert
aff70bb6bd
refactor PatternAs 2022-12-30 18:22:10 +01:00
Folkert
e9196f3c0b
parse and format pattern as 2022-12-30 17:50:17 +01:00
Richard Feldman
8e2eb2b28d
Check if a branch is unreachable 2022-12-29 20:48:45 -05:00
Richard Feldman
e5a0509380
Fix merge issue 2022-12-24 22:32:14 -05:00
Richard Feldman
15d4c2ad68
Don't render undexposed types in docs 2022-12-24 22:32:13 -05:00
Folkert
4ef541395a
remove dbg lowlevel 2022-12-22 02:45:09 +01:00
Richard Feldman
3e448fd2b4
Merge remote-tracking branch 'origin/main' into packages 2022-12-17 03:32:52 -05:00
Richard Feldman
3e5b62db1a
Move exposes into HeaderType 2022-12-13 06:59:25 -05:00
Ayaz Hafiz
50992d35aa
Support printing lambda names in print decls 2022-12-12 14:13:32 -06:00
Ayaz Hafiz
04e1e0cd6e
Support better printing of symbols 2022-12-12 10:38:53 -06:00
Ayaz Hafiz
3a2cd2f7c8
Pretty-print canonicalized declarations 2022-12-12 10:28:23 -06:00
Ayaz Hafiz
7135df6d2f
Move can AST pretty-printing into roc_can::debug 2022-12-12 10:09:32 -06:00
Richard Feldman
e47898dfff
Rename some more header_for to header_type 2022-12-11 03:02:20 -05:00
Richard Feldman
e3687935a3
Merge remote-tracking branch 'origin/main' into refactor-platform-info 2022-12-09 22:21:25 -05:00
Folkert
13d0b75bc1
Merge remote-tracking branch 'origin/main' into expect-print-values 2022-12-08 23:42:03 +01:00
Richard Feldman
97332e4af1
Move ModuleNameEnum into HeaderType 2022-12-08 15:31:43 -05:00
Richard Feldman
87c8702c89
Rename HeaderFor to HeaderType 2022-12-08 15:31:42 -05:00
Ayaz Hafiz
42fe19541e
Define inline expects defs in their definition order
When we transform a top-level expect into an inline expect, we collect
all intermediate defs before the expect condition, then layer the defs
back on. Because the layering procedure builds an expression bottom-up,
we must layer on defs in reverse definition order.

Closes #4705
2022-12-07 10:54:16 -06:00
Ayaz Hafiz
8ca9e6b443
Be more explicit about imported flex and rigid vars 2022-12-05 13:04:15 -06:00
Folkert
7c6cc97cd4
Merge remote-tracking branch 'origin/main' into expect-print-values 2022-12-02 20:28:04 +01:00
Ayaz Hafiz
0f6f34983f
Remove stale comment 2022-12-02 11:50:12 -06:00
Ayaz Hafiz
0a807dc43e
Provide warning for defs that are used only in (mutual) recursion
This patch provides errors for defs that are used only in
possibly-mutual recursion, and are not reachable outside of their
recursive closures. For example:

```
test_report!(
    mutual_recursion_not_reached_nested,
    indoc!(
        r#"
        app "test" provides [main] to "./platform"

        main =
            f = \{} -> if Bool.true then "" else g {}
            g = \{} -> if Bool.true then "" else f {}
            ""
        "#
    ),
@r###"
── DEFINITIONs ONLY USED IN RECURSION ──────────────────── /code/proj/Main.roc ─

These 2 definitions are only used in mutual recursion with themselves:

4│>      f = \{} -> if Bool.true then "" else g {}
5│>      g = \{} -> if Bool.true then "" else f {}

If you don't intend to use or export any of them, they should all be
removed!
"###
);
```
2022-12-02 11:50:12 -06:00
Ayaz Hafiz
34328ddf0c
Unused import 2022-12-02 08:50:04 -06:00
Ayaz Hafiz
078f0147ee
Do not bind accessors in toplevel thunks to their thunks' names
In #3352 an optimization to transform `ra = .field` into

```
ra = \#rcd -[ra]-> #rcd.field
```

rather than

```
__ra1 = \#rcd -[__ra1] -> #rcd.field

ra = LambdaSet { __ra1 }
```

was introduced. However, this optimization is not correct when `ra =
.field` is defined as a toplevel thunk, for in such situations we
indeed want the thunk `ra` to return the lambda set it resolves to,
rather than repointing at itself.

Besides reverting this change, another option would be to convert
accessors into closures before translation of Can to IR. However, this
complicates the translation algorithm more than it already is, and I'd
like to avoid additional special-cases.

Closes #4606
2022-12-02 08:50:03 -06:00
Folkert
1e41aac0f2
lookup symbols when coming from Defs 2022-12-02 15:43:48 +01:00
Folkert
db09d49cd7
implement two todo!'s 2022-12-02 15:43:48 +01:00
Richard Feldman
58fad36f9d
Merge pull request #4460 from roc-lang/crash
Crash
2022-11-25 17:18:21 -05:00
Folkert
bc3414e913
spelling 2022-11-25 18:30:04 +01:00
Folkert
07b7a93b9f
fix not being able to dbg variable 2022-11-25 17:55:01 +01:00
Ayaz Hafiz
eef51c9d87
Correct crash refs 2022-11-24 14:50:39 -06:00
Ayaz Hafiz
e2b30e5301
Constrain + solve crash 2022-11-24 14:46:50 -06:00
Ayaz Hafiz
dd05d813a9
Canonicalize crash 2022-11-24 14:46:49 -06:00
Ayaz
848c18f996
Merge pull request #4567 from joshuawarner32/tuple-type-annotation
Implement tuple type parsing
2022-11-24 14:42:11 -06:00
Joshua Warner
c6b5273144
Implement tuple type parsing
Also change some tests with newly relaxed indentation requirements, and remove an irrelevant test (since unindented close parens are now perfectly valid, the test is no longer useful).
2022-11-24 07:36:59 -08:00
Folkert
1875176319
improve formatting 2022-11-23 23:16:37 +01:00
Folkert
e44a8a9eed
print all the relevant info 2022-11-23 22:58:58 +01:00
Folkert
e7f3c6f281
inline dbg 2022-11-23 21:23:28 +01:00
Folkert
dcb530d3af
Revert "toplevel debug"
This reverts commit 5ea8d96f3e.
2022-11-23 20:29:55 +01:00
Folkert
5ea8d96f3e
toplevel debug 2022-11-23 20:29:45 +01:00