Commit graph

94 commits

Author SHA1 Message Date
Agus Zubiaga
2da7ea394b
Add --main flag to specify app/package to resolve deps from 2024-06-07 17:09:44 -03:00
Agus Zubiaga
8dedd9f03c
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].

    app [main] {
	cli: platform "../platform/main.roc",
	json: "../json/main.roc"
    }

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] 418444862
2024-05-01 10:49:01 -03: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
Agus Zubiaga
eb8ef6241e
Merge branch 'main' into inline-imports 2024-05-01 10:25:17 -03:00
Anton-4
3742ef5f42
update basic-cli links to 0.10 2024-04-28 12:45:31 +02:00
Agus Zubiaga
a8a829aadd
Merge branch 'main' into inline-imports 2024-04-28 00:11:29 -03:00
Richard Feldman
6571c18a35
Update tests 2024-04-25 23:10:45 -04: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
29e59dfec9
upgrade to basic-cli 0.9.1 2024-04-23 19:06:33 +02: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
7ebfc6d06d
Support both inline and header imports
Load will now convert header imports to inline import defs, so that
we can support both temporarily.
2024-04-20 19:04:09 -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
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
Luke Boswell
f9771a9983
split test_utils 2024-04-15 20:30:34 +10:00
Anton-4
e4e1d7116c
update to basic-cli 0.9.0 2024-04-13 12:28:16 +02:00
Anton-4
62cc19c64b
Merge pull request #6597 from jschear/js/double_hash_is_a_doc_comment
Add spaces to doc comments
2024-04-01 16:20:54 +02:00
Brendan Hansknecht
6dc5bfb1b7
Use roc_target over target_lexicon
Tailors a target class for our needs.
Replaces tons of uses across the entire compiler.
This is a base for later adding new targets like thumb.
2024-03-31 10:50:26 -07:00
Jonathan Schear
61f3de4b8f
Run formatter 2024-03-24 18:33:57 -04:00
Jonathan Schear
f511c061ab
Add blank line to test_load for Docs 2024-03-24 14:34:40 -04:00
Anton-4
3fadcf7bcb
style changes 2024-03-16 14:41:08 +01:00
faldor20
45d994d7d7
clippy 2024-03-12 00:18:01 +10:00
faldor20
899dbdd7ec
cleanup tests and whitespace 2024-03-11 16:25:46 +10:00
faldor20
0b56882785
Unannotated types hover 2024-03-11 11:10:35 +10:00
faldor20
cdf218fe7a
first working version of docs hover 2024-03-11 11:10:34 +10:00
Anton-4
b5f68bc020
Merge pull request #6525 from roc-lang/fix_text_contrast
less colors and more contrast in terminal
2024-02-20 15:46:13 +01:00
Anton-4
f66711d53e
re-use strip_colors 2024-02-16 16:32:46 +01:00
Richard Feldman
24a38c4a26
Merge remote-tracking branch 'origin/main' into remove-nat 2024-02-11 12:26:36 -05:00
Anton-4
d08bda6b01
update filenames to new rules 2024-02-09 19:46:39 +01:00
Trevor Settles
cd4adeb9c1
added nicer indentation 2024-02-08 16:37:46 -07:00
Trevor Settles
5f6d259e5d
updated error messages 2024-02-08 15:25:15 -07:00
Trevor Settles
4b4ad47312
added test for no file ext or shebang 2024-02-07 10:18:33 -07:00
Trevor Settles
50c8adbbbb
added test for non roc file 2024-02-06 23:10:18 -07:00
Agus Zubiaga
eb68bf943a
Merge branch 'main' into module-params 2024-01-27 09:36:20 -03:00
Richard Feldman
7e51dfd526
Update test fixtures to not use Nat indices 2024-01-26 16:06:07 -05:00
Richard Feldman
07ddd272e2
Merge pull request #6361 from faldor20/fix-lang-server-hang
Fix hang from bad imports
2024-01-21 22:06:48 -05:00
Agus Zubiaga
002493e32c
Load and can ingested file imports
Moves handling of ingested file imports from load to can, so that they
can be properly introduced in the scope they appear.

Example:

  import "input.txt" as input : Str

  image =
      import "image.png" as bytes : List U8
      # `bytes` is only available under `image`
      decodePng bytes

  ...
2024-01-20 08:43:40 -03:00
Agus Zubiaga
7b3317dbb6
Update unused warnings for inline imports
Now that imports can be limited to smaller scopes than the entire module,
unused import warnings need to work like unused def warnings.

This commit moves unused import warnings discovery and reporting from load
to canonicalization where we can track their usage per scope.

This also fixes a longstanding bug where unused exposed names from an import
were not reported if they were only used in a qualified manner.
2024-01-20 08:43:36 -03:00
Agus Zubiaga
c617963b22
Load and can imports inside defs
After parsing a module, we now recursively traverse the tree to find
all imports inside Defs, not just the top-level ones.

Previously, imported modules were available in the entire file,
but that's no longer the case. Therefore, Scope now keeps track of
imported modules and Env::qualified_lookup checks whether a module
is available in the provided scope.

Note: Unused import warnings are still global and need to be updated.
2024-01-20 08:39:33 -03:00
Agus Zubiaga
710d62f754
Load and can new top-level imports
Previously, all imports were available in the header, so we could start
processing dependencies as soon as we parsed it. However, the new imports
are treated as defs, so we have to parse the whole module to find them.

This commit essentially moves the dependency resolution from the `LoadHeader`
phase to the `Parse` phase, and it updates canonicalization to introduce
module symbols into scope when a `ValueDef::ModuleImport` is encountered.

NOTE:
- The `imports` header still parses, but it's no longer wired up. I will remove
it in an upcoming commit.
- Ingested files and imports that appear in nested expressions are not
yet supported by load
2024-01-20 08:39:31 -03:00
William Barbosa
3882262b70 Fix remaining test cases 2024-01-18 08:15:02 +01:00
faldor20
7de39df63e Just stopping typechecking in interfaces when we have a package import 2024-01-09 06:21:35 +10:00
faldor20
ff7c2cf21b Fixed in interfaces properly 2024-01-07 14:18:32 +10:00
faldor20
d2c3d346ad added test for package 2024-01-07 12:52:31 +10:00
faldor20
f4d71a5485 Finialised error and tested 2024-01-07 12:32:21 +10:00
faldor20
f36befdd4c made nicer error 2024-01-07 11:28:05 +10:00