Commit graph

611 commits

Author SHA1 Message Date
Agus Zubiaga
8a25e4aac4
Handle optional annotation in ingested files when canonicalizing 2024-05-05 16:57:56 -03:00
Anton-4
f7011c8e33
Merge pull request #6644 from roc-lang/rust-1-76-0-upgrade
Rust 1.76.0 upgrade
2024-05-03 07:25:19 +02:00
Agus Zubiaga
057a18573a
New module header
Implements the new `module` header syntax as described in "module and package changes" [1]:

```
module [Request, Response, req]
```

The old syntax should still work fine, and is automatically upgraded to the new one
when running `roc format`.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
2024-05-01 10:39:12 -03:00
Anton-4
c303be7553
Merge branch 'main' into rust-1-76-0-upgrade 2024-04-30 19:36:01 +02:00
Agus Zubiaga
a8a829aadd
Merge branch 'main' into inline-imports 2024-04-28 00:11:29 -03:00
Luke Boswell
74e531b994
remove suffixed from Ident::Access and cleanup 2024-04-28 08:48:08 +10:00
Luke Boswell
20f277c132
update later tests 2024-04-28 08:47:08 +10:00
Luke Boswell
db4607125b
remove suffixed from Pattern 2024-04-28 08:47:08 +10:00
Luke Boswell
2fe03e6c91
remove suffixed from Expr::Var 2024-04-28 08:47:08 +10:00
Luke Boswell
1640ee1321
update logic for Expr::TaskAwaitBang 2024-04-28 08:47:08 +10:00
Joshua Warner
7c53cf0cd7
Fixup tests 2024-04-28 08:47:07 +10:00
Joshua Warner
6080c12ca8
Parse ! suffixes as an Expr::TaskAwaitBang instead of using suffix field in ident 2024-04-28 08:47:07 +10:00
Richard Feldman
6571c18a35
Update tests 2024-04-25 23:10:45 -04:00
Richard Feldman
f557a29090
Don't add Ok and Err as symbols to scope 2024-04-25 20:07:40 -04:00
Agus Zubiaga
e500d664fd
can: Replace AnnotationReferences with plain References
`AnnotationReferences` ignored the fact that within an annotation
the same symbol could be referenced both in a qualified and unqualified
manner.

By using `References` we will properly track all the possible combinations.
2024-04-23 21:16:32 -03:00
Agus Zubiaga
5ca1494df1
Add IdentIds::exposed_values 2024-04-23 20:12:54 -03:00
Agus Zubiaga
0f89d3558a
impl From<ImportedModuleName> for QualifiedModuleName 2024-04-23 20:03:07 -03:00
Agus Zubiaga
f69bc2e46f
Merge branch 'main' into inline-imports 2024-04-23 18:57:20 -03:00
Agus Zubiaga
7efc7a4a3e
Canonicalize ingested files directly instead of creating AST nodes 2024-04-23 18:55:41 -03:00
Anton-4
8902f3e9e3
fix typo
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2024-04-23 12:57:04 +02:00
Agus Zubiaga
6006669702
Report unused imports after canonicalizing platform requires ann 2024-04-22 19:53:19 -03:00
Agus Zubiaga
d952d5576a
Handle explicit builtin imports with empty exposing lists
Also includes related style suggestions by Ayaz on #6658
2024-04-22 18:29:48 -03:00
Agus Zubiaga
66bf955a6e
can/def match => if..let 2024-04-22 17:51:51 -03:00
Agus Zubiaga
d17eb8d340
Remove #[inline] ann for can::Env::module_exists_but_not_imported 2024-04-22 17:47:02 -03:00
Luke Boswell
84cd4233be
clippy fix 2024-04-22 18:55:34 +10:00
Luke Boswell
aa5dc09900
support for more trailing ! 2024-04-22 18:38:51 +10:00
Luke Boswell
32c4083364
add new tests for trailing ! 2024-04-22 18:38:26 +10:00
Agus Zubiaga
5112e064e5
Add module_path to can env instead of threading it through 2024-04-21 10:30:34 -03:00
Agus Zubiaga
e5789158e5
Remove todo on ingested file handling 2024-04-21 10:13:26 -03:00
Agus Zubiaga
7a53484479
Report an error when import shadows a symbol in scope 2024-04-20 12:38:17 -03:00
Agus Zubiaga
979aff8bf7
Explicit builtin import warning
We will now show a warning if a builtin is imported explicitly,
since this is unncessary.

We will not show the warning if they expose functions from the builtin:

	import Dict exposing [isEmpty]

However, we will show a special warning if they expose types from it:

	import Dict exposing [Dict, isEmpty]
2024-04-20 12:35:46 -03:00
Agus Zubiaga
3217e5a3f0
Allow dots in import module names
We found some issues with the private submodules part of the proposal [1],
and we decided to keep module directories for now.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit#heading=h.x84bh32l37em
2024-04-20 12:33:02 -03:00
Agus Zubiaga
b56f029a09
Fix unqualified unused import false positive
If we exposed a symbol in an import and used it both unqualified
and qualified, we'd produce an unused warning false positive.

This happened because we were using a single bit flag to determine
whether a value was used qualified or unqualified.
2024-04-20 12:18:52 -03:00
Agus Zubiaga
1f347f6ca1
Fix package module resolution in inline imports
We were still passing `ModuleIds` from `load` to `can`, but now
that imports can appear in any scope, we don't know which package
an unqualified module name belongs to from the top level.

We now pass `PackageModuleIds` instead  and keep a Map of `ModuleName` to
`ModuleId` in `Scope`.

This also allow us to import multiple modules with the same name from different
packages as long as a unique alias is provided.
2024-04-20 12:16:37 -03:00
Agus Zubiaga
842a256907
Implement import aliases
Allows a module to be imported with an alias:

    import JsonDecode as JD

Import aliases must be unique and they cannot have the same name
as an imported module.
2024-04-20 12:07:01 -03:00
Agus Zubiaga
d5a38a26db
Merge branch 'main' into inline-imports 2024-04-20 12:01:11 -03:00
Richard Feldman
6059f7afcb
Merge pull request #6651 from roc-lang/fix-nesting-suffix
Fix recursion for suffixed `!` in top-level def
2024-04-19 14:53:34 -04:00
Luke Boswell
5e738a4ab5
fix recursion in top-level def 2024-04-19 10:34:33 +10:00
Luke Boswell
ae908f89a9
suffixed when branches 2024-04-18 12:47:11 +10:00
Luke Boswell
a889810dfd
unwrap suffixed when condition 2024-04-18 09:44:57 +10:00
Luke Boswell
0198a683c7
fix unwrapping of trailing expr 2024-04-17 09:54:29 +10:00
Anton-4
99ca3f545f
clippy 2024-04-16 20:02:08 +02:00
Anton-4
1a5e065055
Merge branch 'main' into rust-1-76-0-upgrade 2024-04-16 13:33:27 +02:00
Luke Boswell
7a84dcd39c
don't unwrap intermediate answer if not required 2024-04-16 16:25:20 +10:00
Anton-4
e4b814ce1c
clippy 2024-04-15 16:50:44 +02:00
Luke Boswell
7c94e4db04
cargo fmt 2024-04-15 14:38:20 +10:00
Luke Boswell
ee42dfc317
add support for if-then-else 2024-04-15 14:20:49 +10:00
Luke Boswell
2a222f3a51
optimise by not unwrapping sometimes 2024-04-15 10:02:03 +10:00
Luke Boswell
7886d30b8e
parse/unwrap nested defs 2024-04-15 09:25:00 +10:00
Luke Boswell
129ca94733
remove unit type from EmptyDefsFinal 2024-04-14 13:45:07 +10:00