mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Fix snapshots
This commit is contained in:
parent
a263ddee5e
commit
7a459560ea
8 changed files with 56 additions and 137 deletions
|
|
@ -1221,37 +1221,14 @@ fn processSnapshotContent(
|
|||
.builtin_module = config.builtin_module,
|
||||
};
|
||||
|
||||
// Auto-inject Bool, Try, Str, Dict, and Set as available imports (if they're loaded)
|
||||
// Auto-inject builtin types (Bool, Try, List, Dict, Set, Str, and numeric types) as available imports
|
||||
// This makes them available without needing explicit `import` statements in tests
|
||||
var module_envs = std.AutoHashMap(base.Ident.Idx, Can.AutoImportedType).init(allocator);
|
||||
defer module_envs.deinit();
|
||||
|
||||
// Register each builtin type individually with its statement index
|
||||
// They all point to the same Builtin module env
|
||||
// Note: Str is NOT added because it's handled as a primitive builtin type
|
||||
// in TypeAnno.Builtin.fromBytes() and should never go through module_envs
|
||||
// Use the shared populateModuleEnvs function to ensure consistency with production code
|
||||
if (config.builtin_module) |builtin_env| {
|
||||
const bool_ident = try can_ir.common.idents.insert(allocator, base.Ident.for_text("Bool"));
|
||||
const try_ident = try can_ir.common.idents.insert(allocator, base.Ident.for_text("Try"));
|
||||
const dict_ident = try can_ir.common.idents.insert(allocator, base.Ident.for_text("Dict"));
|
||||
const set_ident = try can_ir.common.idents.insert(allocator, base.Ident.for_text("Set"));
|
||||
|
||||
try module_envs.put(bool_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = config.builtin_indices.bool_type,
|
||||
});
|
||||
try module_envs.put(try_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = config.builtin_indices.try_type,
|
||||
});
|
||||
try module_envs.put(dict_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = config.builtin_indices.dict_type,
|
||||
});
|
||||
try module_envs.put(set_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = config.builtin_indices.set_type,
|
||||
});
|
||||
try Can.populateModuleEnvs(&module_envs, can_ir, builtin_env, config.builtin_indices);
|
||||
}
|
||||
|
||||
var czer = try Can.init(can_ir, &parse_ast, &module_envs);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ main = {
|
|||
# EXPECTED
|
||||
MODULE NOT FOUND - can_import_comprehensive.md:1:1:1:17
|
||||
MODULE NOT FOUND - can_import_comprehensive.md:2:1:2:48
|
||||
DUPLICATE DEFINITION - can_import_comprehensive.md:3:1:3:27
|
||||
MODULE NOT FOUND - can_import_comprehensive.md:3:1:3:27
|
||||
UNDEFINED VARIABLE - can_import_comprehensive.md:6:14:6:22
|
||||
UNDEFINED VARIABLE - can_import_comprehensive.md:7:14:7:23
|
||||
|
|
@ -74,6 +75,24 @@ import http.Client as Http exposing [get, post]
|
|||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
**DUPLICATE DEFINITION**
|
||||
The name `Str` is being redeclared in this scope.
|
||||
|
||||
The redeclaration is here:
|
||||
**can_import_comprehensive.md:3:1:3:27:**
|
||||
```roc
|
||||
import utils.String as Str
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
But `Str` was already defined here:
|
||||
**can_import_comprehensive.md:1:1:1:1:**
|
||||
```roc
|
||||
import json.Json
|
||||
```
|
||||
^
|
||||
|
||||
|
||||
**MODULE NOT FOUND**
|
||||
The module `utils.String` was not found in this Roc project.
|
||||
|
||||
|
|
|
|||
|
|
@ -311,9 +311,6 @@ processData : Config, List(Value) -> Try(List(Value), Error)
|
|||
**DOES NOT EXIST**
|
||||
`List.mapTry` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `mapTry`.
|
||||
|
||||
It's referenced here:
|
||||
**can_import_exposing_types.md:22:5:22:16:**
|
||||
```roc
|
||||
List.mapTry(
|
||||
|
|
@ -801,7 +798,7 @@ combineTrys = |jsonTry, httpStatus|
|
|||
(p-assign (ident "config"))
|
||||
(p-assign (ident "values")))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-runtime-error (tag "qualified_ident_does_not_exist"))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "values")))
|
||||
(e-closure
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ PARSE ERROR - let_polymorphism_lists.md:14:32:14:45
|
|||
UNRECOGNIZED SYNTAX - let_polymorphism_lists.md:12:16:12:27
|
||||
UNRECOGNIZED SYNTAX - let_polymorphism_lists.md:13:16:13:27
|
||||
UNRECOGNIZED SYNTAX - let_polymorphism_lists.md:14:18:14:31
|
||||
DOES NOT EXIST - let_polymorphism_lists.md:25:12:25:20
|
||||
DOES NOT EXIST - let_polymorphism_lists.md:26:12:26:20
|
||||
DOES NOT EXIST - let_polymorphism_lists.md:27:12:27:20
|
||||
# PROBLEMS
|
||||
**UNEXPECTED TOKEN IN EXPRESSION**
|
||||
The token **+** is not expected in an expression.
|
||||
|
|
@ -148,45 +145,6 @@ all_float_list = float_list ++ my_empty_list
|
|||
|
||||
This might be a syntax error, an unsupported language feature, or a typo.
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.len` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `len`.
|
||||
|
||||
It's referenced here:
|
||||
**let_polymorphism_lists.md:25:12:25:20:**
|
||||
```roc
|
||||
len1 = List.len(all_int_list)
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.len` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `len`.
|
||||
|
||||
It's referenced here:
|
||||
**let_polymorphism_lists.md:26:12:26:20:**
|
||||
```roc
|
||||
len2 = List.len(all_str_list)
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.len` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `len`.
|
||||
|
||||
It's referenced here:
|
||||
**let_polymorphism_lists.md:27:12:27:20:**
|
||||
```roc
|
||||
len3 = List.len(all_float_list)
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwApp,OpenSquare,LowerIdent,CloseSquare,OpenCurly,LowerIdent,OpColon,KwPlatform,StringStart,StringPart,StringEnd,CloseCurly,
|
||||
|
|
@ -413,19 +371,22 @@ main = |_| {
|
|||
(s-let
|
||||
(p-assign (ident "len1"))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "all_int_list")))))
|
||||
(s-let
|
||||
(p-assign (ident "len2"))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "all_str_list")))))
|
||||
(s-let
|
||||
(p-assign (ident "len3"))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "all_float_list")))))
|
||||
(e-binop (op "add")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ UNDEFINED VARIABLE - complex_list_tags.md:1:7:1:13
|
|||
DOES NOT EXIST - complex_list_tags.md:3:42:3:51
|
||||
DOES NOT EXIST - complex_list_tags.md:3:59:3:68
|
||||
DOES NOT EXIST - complex_list_tags.md:4:59:4:68
|
||||
DOES NOT EXIST - complex_list_tags.md:4:69:4:77
|
||||
DOES NOT EXIST - complex_list_tags.md:5:62:5:71
|
||||
DOES NOT EXIST - complex_list_tags.md:5:79:5:88
|
||||
DOES NOT EXIST - complex_list_tags.md:5:101:5:110
|
||||
|
|
@ -71,19 +70,6 @@ match events {
|
|||
^^^^^^^^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.len` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `len`.
|
||||
|
||||
It's referenced here:
|
||||
**complex_list_tags.md:4:69:4:77:**
|
||||
```roc
|
||||
[KeyPress(key), .. as rest] => "key ${key} pressed, ${Num.toStr(List.len(rest))} more events"
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`Num.toStr` does not exist.
|
||||
|
||||
|
|
@ -345,7 +331,8 @@ match events {
|
|||
(e-call
|
||||
(e-runtime-error (tag "qualified_ident_does_not_exist"))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "rest")))))
|
||||
(e-literal (string " more events")))))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ match data {
|
|||
~~~
|
||||
# EXPECTED
|
||||
UNDEFINED VARIABLE - nested_patterns.md:1:7:1:11
|
||||
DOES NOT EXIST - nested_patterns.md:2:57:2:65
|
||||
# PROBLEMS
|
||||
**UNDEFINED VARIABLE**
|
||||
Nothing is named `data` in this scope.
|
||||
|
|
@ -27,19 +26,6 @@ match data {
|
|||
^^^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.len` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `len`.
|
||||
|
||||
It's referenced here:
|
||||
**nested_patterns.md:2:57:2:65:**
|
||||
```roc
|
||||
Container({ items: [First(x), .. as rest] }) => x + List.len(rest)
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwMatch,LowerIdent,OpenCurly,
|
||||
|
|
@ -114,7 +100,8 @@ match data {
|
|||
(e-lookup-local
|
||||
(p-assign (ident "x")))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "rest")))))))
|
||||
(branch
|
||||
|
|
@ -143,5 +130,5 @@ match data {
|
|||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (type "Error"))
|
||||
(expr (type "Num(Int(Unsigned64))"))
|
||||
~~~
|
||||
|
|
|
|||
|
|
@ -8,21 +8,9 @@ type=expr
|
|||
List.map
|
||||
~~~
|
||||
# EXPECTED
|
||||
DOES NOT EXIST - simple_external_lookup.md:1:1:1:9
|
||||
NIL
|
||||
# PROBLEMS
|
||||
**DOES NOT EXIST**
|
||||
`List.map` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `map`.
|
||||
|
||||
It's referenced here:
|
||||
**simple_external_lookup.md:1:1:1:9:**
|
||||
```roc
|
||||
List.map
|
||||
```
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
NIL
|
||||
# TOKENS
|
||||
~~~zig
|
||||
UpperIdent,NoSpaceDotLowerIdent,
|
||||
|
|
@ -38,9 +26,10 @@ NO CHANGE
|
|||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (type "Error"))
|
||||
(expr (type "List(a), (a -> b) -> List(b)"))
|
||||
~~~
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ main! = |_| {}
|
|||
~~~
|
||||
# EXPECTED
|
||||
UNEXPECTED TOKEN IN EXPRESSION - type_var_namespace.md:11:31:11:33
|
||||
DOES NOT EXIST - type_var_namespace.md:11:14:11:24
|
||||
UNRECOGNIZED SYNTAX - type_var_namespace.md:11:31:11:33
|
||||
DOES NOT EXIST - type_var_namespace.md:11:34:11:49
|
||||
TYPE MISMATCH - type_var_namespace.md:11:14:11:30
|
||||
# PROBLEMS
|
||||
**UNEXPECTED TOKEN IN EXPRESSION**
|
||||
The token **|>** is not expected in an expression.
|
||||
|
|
@ -39,19 +39,6 @@ Expressions can be identifiers, literals, function calls, or operators.
|
|||
^^
|
||||
|
||||
|
||||
**DOES NOT EXIST**
|
||||
`List.first` does not exist.
|
||||
|
||||
`List` is in scope, but it has no associated `first`.
|
||||
|
||||
It's referenced here:
|
||||
**type_var_namespace.md:11:14:11:24:**
|
||||
```roc
|
||||
result = List.first(list) |> Try.withDefault(elem)
|
||||
```
|
||||
^^^^^^^^^^
|
||||
|
||||
|
||||
**UNRECOGNIZED SYNTAX**
|
||||
I don't recognize this syntax.
|
||||
|
||||
|
|
@ -73,6 +60,20 @@ This might be a syntax error, an unsupported language feature, or a typo.
|
|||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**type_var_namespace.md:11:14:11:30:**
|
||||
```roc
|
||||
result = List.first(list) |> Try.withDefault(elem)
|
||||
```
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
It has the type:
|
||||
_Try(elem, [ListWasEmpty])_
|
||||
|
||||
But the type annotation says it should have the type:
|
||||
_elem_
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwApp,OpenSquare,LowerIdent,CloseSquare,OpenCurly,LowerIdent,OpColon,KwPlatform,StringStart,StringPart,StringEnd,CloseCurly,
|
||||
|
|
@ -171,7 +172,8 @@ main! = |_| {}
|
|||
(s-let
|
||||
(p-assign (ident "result"))
|
||||
(e-call
|
||||
(e-runtime-error (tag "nested_value_not_found"))
|
||||
(e-lookup-external
|
||||
(builtin))
|
||||
(e-lookup-local
|
||||
(p-assign (ident "list")))))
|
||||
(s-expr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue