Commit graph

44 commits

Author SHA1 Message Date
Sam Mohr
ca762127e5
Fix formatting and clippy errors 2024-10-24 23:11:20 -07:00
Sam Mohr
7518a2c5ab
Address PR comments, add syntax tests 2024-10-21 03:06:43 -07:00
Sam Mohr
b3e60f9d3a
Implement return keyword 2024-10-20 08:58:59 -07:00
Elias Mulhall
82d0566041
Use module scope instead of var store to generate idents in dbg desugar
Fix a bug in `dbg` expression desugaring by using the module scope to
generate unique identifiers instead of the variable store.

In the initial implementation of `dbg` expressions we used the
`VarStore` to generate unique identifiers for new variables created
during desugaring. We should have instead used the current module's
`Scope`, which handles identifiers within the module. Each scope has its
own incrementing variable count which is independent of the shared
variable store. The scope is used to generate new identifiers at other
points in canonicalization, such as when assigning a global identifier
to closures and `expect`s. It's possible that the identifier generated
for `dbg` could conflict with an identifier generated by the scope,
resulting in a confusing error.
2024-09-03 14:00:39 -04:00
Agus Zubiaga
49a6b1bfba
Capture whole params record when needed 2024-08-27 11:20:59 -03:00
Agus Zubiaga
b667753a32
Capture import params def 2024-08-26 23:31:42 -03:00
Agus Zubiaga
50887e6265
Capture params in nested defs 2024-08-17 16:13:44 -03:00
Agus Zubiaga
7a8b9f7d6d
Add variable to ParamsVar 2024-08-16 20:54:16 -03:00
Agus Zubiaga
63e722f61d
Rename symbol and module lookup struts 2024-07-06 11:42:53 -03:00
Agus Zubiaga
33cbaa5cd8
Replace ScopeModules/modules VecMap with 2 Vecs 2024-07-05 22:05:33 -03:00
Agus Zubiaga
f80cb341a6
Move ScopeModules to can 2024-07-05 21:35:52 -03:00
Agus Zubiaga
42c58d8efe
Use Vec instead of VecMap for scope module sources 2024-07-02 11:09:59 -03:00
Agus Zubiaga
5aebb7b570
Unqualified lookups return params 2024-07-02 04:10:44 -03: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
Richard Feldman
f557a29090
Don't add Ok and Err as symbols to scope 2024-04-25 20:07:40 -04:00
Agus Zubiaga
7a53484479
Report an error when import shadows a symbol in scope 2024-04-20 12:38:17 -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
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
Bryce Miller
e463ccf4a6
merge main 2023-06-07 20:36:54 -04:00
Ajai Nelson
2e5fef5231
Improve error messages involving ignored variables
Fix #3987
2023-06-06 19:46:15 -04:00
Bryce Miller
cb08225bf0
| -> where 2023-06-05 20:19:00 -04:00
Bryce Miller
d3f6277ea3
has -> implements in comments 2023-05-26 22:59:11 -04:00
Bryce Miller
dbc0204532
abilities syntax has -> implements 2023-05-24 21:30:16 -04:00
Jarl André Hübenthal
8bf888a5e6
chore: replace panic! with internal_error 2023-04-24 10:16:50 +02:00
Ayaz Hafiz
f33651bf6a
Correctly instantiate recursion variables under nested aliases
Like we instantiate nested lambda set variables and nested OIOP
variables for aliases, we need to do the same for recursion variables.
2023-04-12 13:59:24 -05:00
Ayaz Hafiz
debe6332c5
Support OIOP for type aliases 2022-10-31 09:38:21 -05:00
Ayaz Hafiz
f745debc73
Fix scope tests 2022-09-30 13:40:34 -05:00
Ayaz Hafiz
5f117be306
Improve error message when shadowing builtin type
Closes #3109
2022-09-30 13:40:34 -05:00
Ayaz Hafiz
6832d4054f
Better name imported symbols to apply or hint symbols 2022-09-30 13:40:33 -05:00
Ayaz Hafiz
e3c91e1d4d
Can tests 2022-09-20 14:42:09 -05:00
Ayaz Hafiz
75ce40c67d
Make sure ability defs that are possibly recursive are marked as such 2022-07-25 10:52:55 -04:00
Ayaz Hafiz
bf8fc0d0de
Permit binding variables multiple itmes in when branches 2022-07-21 11:06:40 -04:00
Ayaz Hafiz
cf158d21ed
Fix comment 2022-07-19 14:30:20 -04:00
Ayaz Hafiz
7586a8a083
Check complete ability implementations during canonicalization 2022-07-19 14:30:20 -04:00
Ayaz Hafiz
d2da395619
Syntactic ability links in solve 2022-07-18 18:33:28 -04:00
Ayaz Hafiz
c2154ac311
Support shorthand ability implementation syntax 2022-07-18 17:55:01 -04:00
Ayaz Hafiz
96b32c36cb
Introdue ability member names before other value names 2022-07-18 17:55:01 -04:00
Ayaz Hafiz
e672ce9ebd
First pass at canonicalizing and reporting syntactic abilities 2022-07-18 17:55:01 -04:00
Folkert
b6224a3806
ugly hack to make the docs build 2022-07-14 22:15:19 +02:00
Folkert
96414cb03f
cleanup 2022-07-14 08:52:38 +02:00
Folkert
cbd6052dbb
fix dict/set not being in scope 2022-07-13 14:04:38 +02:00
Anton-4
eee85fa45d
moved all crates into seperate folder + related path fixes 2022-07-01 17:37:43 +02:00
Renamed from compiler/can/src/scope.rs (Browse further)