mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Fix statement snapshots, implement more Can for type annotations
This commit is contained in:
parent
32710be5bc
commit
05ad361244
47 changed files with 596 additions and 204 deletions
|
@ -2760,7 +2760,8 @@ fn canonicalize_type_header(self: *Self, header_idx: AST.TypeHeader.Idx) CIR.Typ
|
|||
});
|
||||
}
|
||||
|
||||
fn canonicalize_statement(self: *Self, stmt_idx: AST.Statement.Idx) ?CIR.Expr.Idx {
|
||||
/// Canonicalize a statement in the canonical IR.
|
||||
pub fn canonicalize_statement(self: *Self, stmt_idx: AST.Statement.Idx) ?CIR.Expr.Idx {
|
||||
const stmt = self.parse_ir.store.getStatement(stmt_idx);
|
||||
|
||||
switch (stmt) {
|
||||
|
@ -2909,16 +2910,44 @@ fn canonicalize_statement(self: *Self, stmt_idx: AST.Statement.Idx) ?CIR.Expr.Id
|
|||
} });
|
||||
};
|
||||
|
||||
// Canonicalize the type annotation
|
||||
const type_anno_idx = self.canonicalize_type_anno(ta.anno);
|
||||
// First, extract all type variables from the AST annotation
|
||||
var type_vars = std.ArrayList(Ident.Idx).init(self.can_ir.env.gpa);
|
||||
defer type_vars.deinit();
|
||||
self.extractTypeVarsFromASTAnno(ta.anno, &type_vars);
|
||||
|
||||
// Extract type variables from the annotation and introduce them into scope
|
||||
// This makes them available for the subsequent value declaration
|
||||
self.extractTypeVarsFromAnno(type_anno_idx);
|
||||
// Enter a new scope for type variables
|
||||
self.scopeEnter(self.can_ir.env.gpa, false);
|
||||
defer self.scopeExit(self.can_ir.env.gpa) catch {};
|
||||
|
||||
// Introduce type variables into scope
|
||||
for (type_vars.items) |type_var| {
|
||||
// Create a dummy type annotation for the type variable
|
||||
const type_var_region = Region.zero(); // TODO: get proper region from type variable
|
||||
const dummy_anno = self.can_ir.store.addTypeAnno(.{ .ty_var = .{
|
||||
.name = type_var,
|
||||
.region = type_var_region,
|
||||
} });
|
||||
self.scopeIntroduceTypeVar(type_var, dummy_anno);
|
||||
}
|
||||
|
||||
// Now canonicalize the annotation with type variables in scope
|
||||
const type_anno_idx = self.canonicalize_type_anno(ta.anno);
|
||||
|
||||
// Store the type annotation for connection with the next declaration
|
||||
self.pending_type_annos.append(self.can_ir.env.gpa, .{ .ident = name_ident, .anno = type_anno_idx }) catch |err| exitOnOom(err);
|
||||
|
||||
// Create a type annotation statement
|
||||
const type_anno_stmt = CIR.Statement{
|
||||
.type_anno = .{
|
||||
.name = name_ident,
|
||||
.anno = type_anno_idx,
|
||||
.where = null, // TODO: handle where clauses when they're implemented
|
||||
.region = region,
|
||||
},
|
||||
};
|
||||
const type_anno_stmt_idx = self.can_ir.store.addStatement(type_anno_stmt);
|
||||
self.can_ir.store.addScratchStatement(type_anno_stmt_idx);
|
||||
|
||||
// Type annotations don't produce runtime values, so return a unit expression
|
||||
// Create an empty tuple as a unit value
|
||||
const empty_span = CIR.Expr.Span{ .span = base.DataSpan{ .start = 0, .len = 0 } };
|
||||
|
@ -3119,9 +3148,13 @@ fn extractTypeVarsFromAnno(self: *Self, type_anno_idx: CIR.TypeAnno.Idx) void {
|
|||
self.extractTypeVarsFromAnno(arg_idx);
|
||||
}
|
||||
},
|
||||
.@"fn" => {
|
||||
// Function type annotations are not yet implemented in CIR
|
||||
// When implemented, extract from parameter and return types
|
||||
.@"fn" => |fn_anno| {
|
||||
// Extract type variables from function parameter types
|
||||
for (self.can_ir.store.sliceTypeAnnos(fn_anno.args)) |param_idx| {
|
||||
self.extractTypeVarsFromAnno(param_idx);
|
||||
}
|
||||
// Extract type variables from return type
|
||||
self.extractTypeVarsFromAnno(fn_anno.ret);
|
||||
},
|
||||
.tuple => |tuple| {
|
||||
// Extract from tuple elements
|
||||
|
@ -3133,7 +3166,14 @@ fn extractTypeVarsFromAnno(self: *Self, type_anno_idx: CIR.TypeAnno.Idx) void {
|
|||
// Extract from inner annotation
|
||||
self.extractTypeVarsFromAnno(parens.anno);
|
||||
},
|
||||
.ty, .underscore, .mod_ty, .record, .tag_union, .malformed => {
|
||||
.record => |record| {
|
||||
// Extract type variables from record field types
|
||||
for (self.can_ir.store.sliceAnnoRecordFields(record.fields)) |field_idx| {
|
||||
const field = self.can_ir.store.getAnnoRecordField(field_idx);
|
||||
self.extractTypeVarsFromAnno(field.ty);
|
||||
}
|
||||
},
|
||||
.ty, .underscore, .mod_ty, .tag_union, .malformed => {
|
||||
// These don't contain type variables to extract
|
||||
},
|
||||
}
|
||||
|
@ -3183,7 +3223,14 @@ fn extractTypeVarsFromASTAnno(self: *Self, anno_idx: AST.TypeAnno.Idx, vars: *st
|
|||
.parens => |parens| {
|
||||
self.extractTypeVarsFromASTAnno(parens.anno, vars);
|
||||
},
|
||||
.ty, .underscore, .mod_ty, .record, .tag_union, .malformed => {
|
||||
.record => |record| {
|
||||
// Extract type variables from record field types
|
||||
for (self.parse_ir.store.annoRecordFieldSlice(record.fields)) |field_idx| {
|
||||
const field = self.parse_ir.store.getAnnoRecordField(field_idx);
|
||||
self.extractTypeVarsFromASTAnno(field.ty, vars);
|
||||
}
|
||||
},
|
||||
.ty, .underscore, .mod_ty, .tag_union, .malformed => {
|
||||
// These don't contain type variables to extract
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1548,7 +1548,11 @@ fn processSnapshotFileUnified(gpa: Allocator, snapshot_path: []const u8, maybe_f
|
|||
maybe_expr_idx = can.canonicalize_expr(expr_idx);
|
||||
},
|
||||
.statement => {
|
||||
// TODO: implement canonicalize_statement when available
|
||||
// Manually track scratch statements because we aren't using the file entrypoint
|
||||
const stmt_idx: AST.Statement.Idx = @enumFromInt(parse_ast.root_node_idx);
|
||||
const scratch_statements_start = can_ir.store.scratch_statements.top();
|
||||
_ = can.canonicalize_statement(stmt_idx);
|
||||
can_ir.all_statements = can_ir.store.statementSpanFrom(scratch_statements_start);
|
||||
},
|
||||
}
|
||||
|
||||
|
|
9
src/snapshots/can_dot_access.md
generated
9
src/snapshots/can_dot_access.md
generated
|
@ -23,11 +23,10 @@ LowerIdent(1:1-1:5),NoSpaceDotLowerIdent(1:5-1:9),NoSpaceOpenRound(1:9-1:10),Low
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-1-13
|
||||
(e-binop @1-1-1-13 (op "list")
|
||||
(e-ident @1-1-1-5 (qaul "") (raw "list"))
|
||||
(e-apply @1-5-1-13
|
||||
(e-ident @1-5-1-9 (qaul "") (raw ".map"))
|
||||
(e-ident @1-10-1-12 (qaul "") (raw "fn")))))
|
||||
(e-ident @1-1-1-5 (qaul "") (raw "list"))
|
||||
(e-apply @1-5-1-13
|
||||
(e-ident @1-5-1-9 (qaul "") (raw ".map"))
|
||||
(e-ident @1-10-1-12 (qaul "") (raw "fn"))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
9
src/snapshots/can_dot_access_with_vars.md
generated
9
src/snapshots/can_dot_access_with_vars.md
generated
|
@ -40,11 +40,10 @@ CloseCurly(5:1-5:2),EndOfFile(5:2-5:2),
|
|||
(e-ident @3-14-3-15 (qaul "") (raw "x"))
|
||||
(e-int @3-18-3-19 (raw "1")))))
|
||||
(e-field-access @4-5-5-2
|
||||
(e-binop @4-5-5-2 (op "{")
|
||||
(e-ident @4-5-4-9 (qaul "") (raw "list"))
|
||||
(e-apply @4-9-4-17
|
||||
(e-ident @4-9-4-13 (qaul "") (raw ".map"))
|
||||
(e-ident @4-14-4-16 (qaul "") (raw "fn")))))))
|
||||
(e-ident @4-5-4-9 (qaul "") (raw "list"))
|
||||
(e-apply @4-9-4-17
|
||||
(e-ident @4-9-4-13 (qaul "") (raw ".map"))
|
||||
(e-ident @4-14-4-16 (qaul "") (raw "fn"))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
|
@ -19,9 +19,8 @@ LowerIdent(1:1-1:7),NoSpaceDotLowerIdent(1:7-1:12),EndOfFile(1:12-1:12),
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-1-12
|
||||
(e-binop @1-1-1-12 (op "person")
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-12 (qaul "") (raw ".name"))))
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-12 (qaul "") (raw ".name")))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
|
@ -21,6 +21,10 @@ OpenCurly(1:1-1:2),CloseCurly(1:2-1:3),EndOfFile(1:3-1:3),
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-empty_record @1-1-1-3 (id 72))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 72) (type "{}"))
|
||||
|
|
|
@ -60,13 +60,15 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:9),OpAmpersand(1:10-1:11),LowerIdent(1:12-1:
|
|||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-block @1-1-1-21 (id 79)
|
||||
(e-block @1-1-1-21 (id 80)
|
||||
(s-expr @1-3-1-11
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(e-tuple @1-12-1-21 (tuple-var 77)
|
||||
(s-type-anno @1-12-1-21 (name "age")
|
||||
(ty-malformed @1-17-1-21))
|
||||
(e-tuple @1-12-1-21 (tuple-var 78)
|
||||
(elems)))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 79) (type "*"))
|
||||
(expr (id 80) (type "*"))
|
||||
~~~
|
|
@ -24,23 +24,20 @@ DotLowerIdent(4:2-4:15),NoSpaceOpQuestion(4:15-4:16),EndOfFile(4:16-4:16),
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-4-16
|
||||
(e-binop @1-1-4-16 (op "some_fn")
|
||||
(e-field-access @1-1-4-15
|
||||
(e-binop @1-1-4-15 (op "some_fn")
|
||||
(e-field-access @1-1-3-30
|
||||
(e-binop @1-1-3-30 (op "some_fn")
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @2-2-2-28
|
||||
(e-apply @2-2-2-27
|
||||
(e-ident @2-2-2-25 (qaul "") (raw ".static_dispatch_method"))))))
|
||||
(e-question-suffix @3-2-3-33
|
||||
(e-apply @3-2-3-32
|
||||
(e-ident @3-2-3-30 (qaul "") (raw ".next_static_dispatch_method"))))))
|
||||
(e-question-suffix @4-2-4-16
|
||||
(e-ident @4-2-4-15 (qaul "") (raw ".record_field")))))
|
||||
(e-field-access @1-1-4-15
|
||||
(e-field-access @1-1-3-30
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @2-2-2-28
|
||||
(e-apply @2-2-2-27
|
||||
(e-ident @2-2-2-25 (qaul "") (raw ".static_dispatch_method")))))
|
||||
(e-question-suffix @3-2-3-33
|
||||
(e-apply @3-2-3-32
|
||||
(e-ident @3-2-3-30 (qaul "") (raw ".next_static_dispatch_method")))))
|
||||
(e-question-suffix @4-2-4-16
|
||||
(e-ident @4-2-4-15 (qaul "") (raw ".record_field"))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
|
@ -24,23 +24,20 @@ DotLowerIdent(4:2-4:15),NoSpaceOpQuestion(4:15-4:16),EndOfFile(4:16-4:16),
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-4-16
|
||||
(e-binop @1-1-4-16 (op "some_fn")
|
||||
(e-field-access @1-1-4-15
|
||||
(e-binop @1-1-4-15 (op "some_fn")
|
||||
(e-field-access @1-1-3-30
|
||||
(e-binop @1-1-3-30 (op "some_fn")
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @2-2-2-28
|
||||
(e-apply @2-2-2-27
|
||||
(e-ident @2-2-2-25 (qaul "") (raw ".static_dispatch_method"))))))
|
||||
(e-question-suffix @3-2-3-33
|
||||
(e-apply @3-2-3-32
|
||||
(e-ident @3-2-3-30 (qaul "") (raw ".next_static_dispatch_method"))))))
|
||||
(e-question-suffix @4-2-4-16
|
||||
(e-ident @4-2-4-15 (qaul "") (raw ".record_field")))))
|
||||
(e-field-access @1-1-4-15
|
||||
(e-field-access @1-1-3-30
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @2-2-2-28
|
||||
(e-apply @2-2-2-27
|
||||
(e-ident @2-2-2-25 (qaul "") (raw ".static_dispatch_method")))))
|
||||
(e-question-suffix @3-2-3-33
|
||||
(e-apply @3-2-3-32
|
||||
(e-ident @3-2-3-30 (qaul "") (raw ".next_static_dispatch_method")))))
|
||||
(e-question-suffix @4-2-4-16
|
||||
(e-ident @4-2-4-15 (qaul "") (raw ".record_field"))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
|
@ -41,6 +41,10 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),OpColon(1:7-1:8),StringStart(1:9-1:10),St
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -5,38 +5,39 @@ type=expr
|
|||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
{ name = "Alice" }
|
||||
{ age: 42, name = "Alice" }
|
||||
~~~
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable ``name`` is not used anywhere in your code.
|
||||
**PARSE ERROR**
|
||||
A parsing error occurred: `expected_expr_close_curly_or_comma`
|
||||
This is an unexpected parsing error. Please check your syntax.
|
||||
|
||||
If you don't need this variable, prefix it with an underscore like `_name` to suppress this warning.
|
||||
The unused variable is declared here:
|
||||
**error_malformed_syntax_2.md:1:3:1:7:**
|
||||
Here is the problematic code:
|
||||
**error_malformed_syntax_2.md:1:17:1:20:**
|
||||
```roc
|
||||
{ name = "Alice" }
|
||||
{ age: 42, name = "Alice" }
|
||||
```
|
||||
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),OpAssign(1:8-1:9),StringStart(1:10-1:11),StringPart(1:11-1:16),StringEnd(1:16-1:17),CloseCurly(1:18-1:19),EndOfFile(1:19-1:19),
|
||||
OpenCurly(1:1-1:2),LowerIdent(1:3-1:6),OpColon(1:6-1:7),Int(1:8-1:10),Comma(1:10-1:11),LowerIdent(1:12-1:16),OpAssign(1:17-1:18),StringStart(1:19-1:20),StringPart(1:20-1:25),StringEnd(1:25-1:26),CloseCurly(1:27-1:28),EndOfFile(1:28-1:28),
|
||||
~~~
|
||||
# PARSE
|
||||
~~~clojure
|
||||
(e-block @1-1-1-19
|
||||
(statements
|
||||
(s-decl @1-3-1-17
|
||||
(p-ident @1-3-1-7 (raw "name"))
|
||||
(e-string @1-10-1-17
|
||||
(e-string-part @1-11-1-16 (raw "Alice"))))))
|
||||
(e-malformed @1-17-1-20 (reason "expected_expr_close_curly_or_comma"))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
name = "Alice"
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 76) (type "*"))
|
||||
(inferred-types
|
||||
(defs)
|
||||
(expressions))
|
||||
~~~
|
|
@ -52,6 +52,10 @@ OpBar(1:1-1:2),OpenCurly(1:2-1:3),LowerIdent(1:4-1:8),Comma(1:8-1:9),LowerIdent(
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -52,6 +52,10 @@ OpBar(1:1-1:2),OpenCurly(1:2-1:3),LowerIdent(1:4-1:8),Comma(1:8-1:9),LowerIdent(
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -52,6 +52,10 @@ OpBar(1:1-1:2),OpenCurly(1:2-1:3),LowerIdent(1:4-1:14),Comma(1:14-1:15),DoubleDo
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -71,6 +71,10 @@ CloseCurly(3:1-3:2),EndOfFile(3:2-3:2),
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -60,6 +60,10 @@ CloseCurly(3:1-3:2),EndOfFile(3:2-3:2),
|
|||
# FORMATTED
|
||||
~~~roc
|
||||
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
|
|
|
@ -56,6 +56,10 @@ match person {
|
|||
=> name
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-runtime-error (tag "not_implemented") (id 73))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 73) (type "Error"))
|
||||
|
|
|
@ -55,9 +55,8 @@ CloseCurly(3:1-3:2),EndOfFile(3:2-3:2),
|
|||
(e-apply @2-55-2-80
|
||||
(e-ident @2-55-2-62 (qaul "Str") (raw ".len"))
|
||||
(e-field-access @2-63-2-80
|
||||
(e-binop @2-63-2-80 (op "match")
|
||||
(e-ident @2-63-2-69 (qaul "") (raw "others"))
|
||||
(e-ident @2-69-2-79 (qaul "") (raw ".last_name")))))))))
|
||||
(e-ident @2-63-2-69 (qaul "") (raw "others"))
|
||||
(e-ident @2-69-2-79 (qaul "") (raw ".last_name"))))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
@ -65,6 +64,10 @@ match person {
|
|||
=> Str.len(first_name) > Str.len(others.last_name)
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-runtime-error (tag "not_implemented") (id 73))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 73) (type "Error"))
|
||||
|
|
|
@ -55,6 +55,10 @@ LowerIdent(1:1-1:11),OpAssign(1:12-1:13),OpBar(1:14-1:15),OpenCurly(1:15-1:16),L
|
|||
~~~roc
|
||||
formatUser =
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -21,15 +21,24 @@ OpenRound(1:1-1:2),LowerIdent(1:2-1:8),NoSpaceDotLowerIdent(1:8-1:18),CloseRound
|
|||
(e-apply @1-1-1-23
|
||||
(e-tuple @1-1-1-19
|
||||
(e-field-access @1-2-1-19
|
||||
(e-binop @1-2-1-19 (op "(")
|
||||
(e-ident @1-2-1-8 (qaul "") (raw "person"))
|
||||
(e-ident @1-8-1-18 (qaul "") (raw ".transform")))))
|
||||
(e-ident @1-2-1-8 (qaul "") (raw "person"))
|
||||
(e-ident @1-8-1-18 (qaul "") (raw ".transform"))))
|
||||
(e-int @1-20-1-22 (raw "42")))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-call @1-1-1-23 (id 80)
|
||||
(e-tuple @1-1-1-19 (tuple-var 75)
|
||||
(elems
|
||||
(e-dot-access @1-2-1-19 (field "transform")
|
||||
(receiver
|
||||
(e-runtime-error (tag "ident_not_in_scope"))))))
|
||||
(e-int @1-20-1-22 (num-var 79) (sign-needed "false") (bits-needed "7") (value "42")))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 80) (type "*"))
|
||||
|
|
|
@ -20,15 +20,22 @@ LowerIdent(1:1-1:7),NoSpaceDotLowerIdent(1:7-1:11),OpPlus(1:12-1:13),Int(1:14-1:
|
|||
~~~clojure
|
||||
(e-binop @1-1-1-15 (op "+")
|
||||
(e-field-access @1-1-1-13
|
||||
(e-binop @1-1-1-13 (op "person")
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-11 (qaul "") (raw ".age"))))
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-11 (qaul "") (raw ".age")))
|
||||
(e-int @1-14-1-15 (raw "5")))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-binop @1-1-1-15 (op "add") (id 78)
|
||||
(e-dot-access @1-1-1-13 (field "age")
|
||||
(receiver
|
||||
(e-runtime-error (tag "ident_not_in_scope"))))
|
||||
(e-int @1-14-1-15 (num-var 77) (sign-needed "false") (bits-needed "7") (value "5")))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 78) (type "*"))
|
||||
|
|
|
@ -19,17 +19,23 @@ LowerIdent(1:1-1:7),NoSpaceDotLowerIdent(1:7-1:15),NoSpaceDotLowerIdent(1:15-1:2
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-1-22
|
||||
(e-binop @1-1-1-22 (op "person")
|
||||
(e-field-access @1-1-1-22
|
||||
(e-binop @1-1-1-22 (op "person")
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-15 (qaul "") (raw ".address"))))
|
||||
(e-ident @1-15-1-22 (qaul "") (raw ".street"))))
|
||||
(e-field-access @1-1-1-22
|
||||
(e-ident @1-1-1-7 (qaul "") (raw "person"))
|
||||
(e-ident @1-7-1-15 (qaul "") (raw ".address")))
|
||||
(e-ident @1-15-1-22 (qaul "") (raw ".street")))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-dot-access @1-1-1-22 (field "street") (id 75)
|
||||
(receiver
|
||||
(e-dot-access @1-1-1-22 (field "address")
|
||||
(receiver
|
||||
(e-runtime-error (tag "ident_not_in_scope"))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 75) (type "*"))
|
||||
|
|
|
@ -343,7 +343,37 @@ CloseCurly(8:1-8:2),EndOfFile(8:2-8:2),
|
|||
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-block @1-1-8-2 (id 112)
|
||||
(s-type-anno @2-5-2-39 (name "_privateField")
|
||||
(ty-malformed @2-20-2-39))
|
||||
(s-type-anno @3-5-3-33 (name "field_")
|
||||
(ty-malformed @3-13-3-33))
|
||||
(s-expr @4-5-4-16
|
||||
(e-tag @4-5-4-15 (ext-var 0) (name "PascalCase") (args "TODO")))
|
||||
(s-expr @4-17-4-26
|
||||
(e-string @4-17-4-25
|
||||
(e-literal @4-18-4-24 (string "pascal"))))
|
||||
(s-expr @5-5-5-16
|
||||
(e-binop @5-5-5-16 (op "sub")
|
||||
(e-runtime-error (tag "ident_not_in_scope"))
|
||||
(e-runtime-error (tag "ident_not_in_scope"))))
|
||||
(s-expr @5-17-5-25
|
||||
(e-string @5-17-5-24
|
||||
(e-literal @5-18-5-23 (string "kebab"))))
|
||||
(s-expr @6-5-6-11
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(s-type-anno @6-11-6-27 (name "special")
|
||||
(ty-malformed @6-20-6-27))
|
||||
(s-expr @7-5-7-17
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(s-expr @7-19-7-31
|
||||
(e-string @7-19-7-30
|
||||
(e-literal @7-20-7-29 (string "at symbol"))))
|
||||
(e-empty_record @1-1-8-2))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 109) (type "*"))
|
||||
(expr (id 112) (type "*"))
|
||||
~~~
|
|
@ -42,6 +42,20 @@ CloseCurly(5:1-5:2),EndOfFile(5:2-5:2),
|
|||
camelCase: "camel",
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-5-2 (record-var 81) (ext-var 0) (id 83)
|
||||
(fields
|
||||
(field (name "field_with_underscores")
|
||||
(e-string @2-29-2-41
|
||||
(e-literal @2-30-2-40 (string "underscore"))))
|
||||
(field (name "field123")
|
||||
(e-string @3-15-3-24
|
||||
(e-literal @3-16-3-23 (string "numbers"))))
|
||||
(field (name "camelCase")
|
||||
(e-string @4-16-4-23
|
||||
(e-literal @4-17-4-22 (string "camel"))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 83) (type "*"))
|
||||
|
|
|
@ -284,7 +284,24 @@ CloseCurly(8:1-8:2),EndOfFile(8:2-8:2),
|
|||
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-block @1-1-8-2 (id 94)
|
||||
(s-type-anno @3-5-3-25 (name "when")
|
||||
(ty-malformed @3-11-3-25))
|
||||
(s-expr @4-13-4-30
|
||||
(e-string @4-13-4-29
|
||||
(e-literal @4-14-4-28 (string "test assertion"))))
|
||||
(s-expr @5-13-5-27
|
||||
(e-string @5-13-5-26
|
||||
(e-literal @5-14-5-25 (string "module load"))))
|
||||
(s-expr @6-10-6-20
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(s-expr @7-9-7-20
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(e-empty_record @1-1-8-2))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 93) (type "*"))
|
||||
(expr (id 94) (type "*"))
|
||||
~~~
|
|
@ -106,7 +106,18 @@ CloseCurly(4:1-4:2),EndOfFile(4:2-4:2),
|
|||
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-block @1-1-4-2 (id 85)
|
||||
(s-expr @1-3-1-11
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(s-type-anno @2-5-2-13 (name "age")
|
||||
(ty-malformed @2-10-2-13))
|
||||
(s-type-anno @3-5-3-22 (name "active")
|
||||
(ty @3-13-3-17 (name "Bool")))
|
||||
(e-empty_record @1-1-4-2))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 83) (type "*"))
|
||||
(expr (id 85) (type "*"))
|
||||
~~~
|
|
@ -29,6 +29,16 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),Comma(1:7-1:8),LowerIdent(1:9-1:12),OpCol
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-1-52 (record-var 79) (ext-var 0) (id 81)
|
||||
(fields
|
||||
(field (name "age")
|
||||
(e-int @1-14-1-16 (num-var 74) (sign-needed "false") (bits-needed "7") (value "30")))
|
||||
(field (name "status")
|
||||
(e-string @1-33-1-41
|
||||
(e-literal @1-34-1-40 (string "active"))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 81) (type "*"))
|
||||
|
|
|
@ -38,6 +38,26 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),OpColon(1:7-1:8),StringStart(1:9-1:10),St
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-1-86 (record-var 98) (ext-var 0) (id 100)
|
||||
(fields
|
||||
(field (name "name")
|
||||
(e-string @1-9-1-16
|
||||
(e-literal @1-10-1-15 (string "Alice"))))
|
||||
(field (name "age")
|
||||
(e-int @1-23-1-25 (num-var 77) (sign-needed "false") (bits-needed "7") (value "30")))
|
||||
(field (name "active")
|
||||
(e-runtime-error (tag "ident_not_in_scope")))
|
||||
(field (name "scores")
|
||||
(e-list @1-54-1-66 (elem-var 91)
|
||||
(elems
|
||||
(e-int @1-55-1-57 (num-var 84) (sign-needed "false") (bits-needed "7") (value "95"))
|
||||
(e-int @1-59-1-61 (num-var 87) (sign-needed "false") (bits-needed "7") (value "87"))
|
||||
(e-int @1-63-1-65 (num-var 90) (sign-needed "false") (bits-needed "7") (value "92")))))
|
||||
(field (name "balance")
|
||||
(e-frac-dec @1-77-1-84 (frac-var 96) (fits-in-f32 "true") (fits-in-dec "true") (value "1250.75")))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 100) (type "*"))
|
||||
|
|
|
@ -88,6 +88,50 @@ CloseCurly(12:1-12:2),EndOfFile(12:2-12:2),
|
|||
},
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-12-2 (record-var 122) (ext-var 0) (id 124)
|
||||
(fields
|
||||
(field (name "person")
|
||||
(e-record @2-13-2-39 (record-var 79) (ext-var 0)
|
||||
(fields
|
||||
(field (name "name")
|
||||
(e-string @2-21-2-28
|
||||
(e-literal @2-22-2-27 (string "Alice"))))
|
||||
(field (name "age")
|
||||
(e-int @2-35-2-37 (num-var 77) (sign-needed "false") (bits-needed "7") (value "30"))))))
|
||||
(field (name "address")
|
||||
(e-record @3-14-7-6 (record-var 101) (ext-var 0)
|
||||
(fields
|
||||
(field (name "street")
|
||||
(e-string @4-17-4-30
|
||||
(e-literal @4-18-4-29 (string "123 Main St"))))
|
||||
(field (name "city")
|
||||
(e-string @5-15-5-28
|
||||
(e-literal @5-16-5-27 (string "Springfield"))))
|
||||
(field (name "coordinates")
|
||||
(e-record @6-22-6-53 (record-var 97) (ext-var 0)
|
||||
(fields
|
||||
(field (name "lat")
|
||||
(e-frac-dec @6-29-6-36 (frac-var 91) (fits-in-f32 "true") (fits-in-dec "true") (value "42.1234")))
|
||||
(field (name "lng")
|
||||
(e-frac-dec @6-43-6-51 (frac-var 95) (fits-in-f32 "true") (fits-in-dec "true") (value "-71.5678")))))))))
|
||||
(field (name "contact")
|
||||
(e-record @8-14-11-6 (record-var 118) (ext-var 0)
|
||||
(fields
|
||||
(field (name "email")
|
||||
(e-string @9-16-9-35
|
||||
(e-literal @9-17-9-34 (string "alice@example.com"))))
|
||||
(field (name "phone")
|
||||
(e-record @10-16-10-54 (record-var 114) (ext-var 0)
|
||||
(fields
|
||||
(field (name "home")
|
||||
(e-string @10-24-10-34
|
||||
(e-literal @10-25-10-33 (string "555-1234"))))
|
||||
(field (name "work")
|
||||
(e-string @10-42-10-52
|
||||
(e-literal @10-43-10-51 (string "555-5678"))))))))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 124) (type "*"))
|
||||
|
|
|
@ -25,6 +25,11 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),Comma(1:7-1:8),LowerIdent(1:9-1:12),Comma
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-1-29 (record-var 0) (ext-var 0) (id 74)
|
||||
(fields))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 74) (type "*"))
|
||||
|
|
|
@ -139,6 +139,96 @@ CloseCurly(15:1-15:2),EndOfFile(15:2-15:2),
|
|||
},
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(e-record @1-1-15-2 (record-var 187) (ext-var 0) (id 189)
|
||||
(fields
|
||||
(field (name "name")
|
||||
(e-string @2-11-2-18
|
||||
(e-literal @2-12-2-17 (string "Alice"))))
|
||||
(field (name "scores")
|
||||
(e-list @3-13-3-29 (elem-var 87)
|
||||
(elems
|
||||
(e-int @3-14-3-16 (num-var 77) (sign-needed "false") (bits-needed "7") (value "95"))
|
||||
(e-int @3-18-3-20 (num-var 80) (sign-needed "false") (bits-needed "7") (value "87"))
|
||||
(e-int @3-22-3-24 (num-var 83) (sign-needed "false") (bits-needed "7") (value "92"))
|
||||
(e-int @3-26-3-28 (num-var 86) (sign-needed "false") (bits-needed "7") (value "78")))))
|
||||
(field (name "status")
|
||||
(e-call @4-13-4-44
|
||||
(e-tag @4-13-4-19 (ext-var 0) (name "Active") (args "TODO"))
|
||||
(e-record @4-20-4-43 (record-var 95) (ext-var 0)
|
||||
(fields
|
||||
(field (name "since")
|
||||
(e-string @4-29-4-41
|
||||
(e-literal @4-30-4-40 (string "2023-01-15"))))))))
|
||||
(field (name "preferences")
|
||||
(e-record @5-18-5-76 (record-var 109) (ext-var 0)
|
||||
(fields
|
||||
(field (name "theme")
|
||||
(e-tag @5-27-5-31 (ext-var 0) (name "Dark") (args "TODO")))
|
||||
(field (name "notifications")
|
||||
(e-call @5-48-5-74
|
||||
(e-tag @5-48-5-53 (ext-var 0) (name "Email") (args "TODO"))
|
||||
(e-string @5-54-5-73
|
||||
(e-literal @5-55-5-72 (string "alice@example.com"))))))))
|
||||
(field (name "metadata")
|
||||
(e-call @6-15-9-7
|
||||
(e-tag @6-15-6-17 (ext-var 0) (name "Ok") (args "TODO"))
|
||||
(e-record @6-18-9-6 (record-var 133) (ext-var 0)
|
||||
(fields
|
||||
(field (name "tags")
|
||||
(e-list @7-15-7-51 (elem-var 121)
|
||||
(elems
|
||||
(e-string @7-16-7-27
|
||||
(e-literal @7-17-7-26 (string "developer")))
|
||||
(e-string @7-29-7-37
|
||||
(e-literal @7-30-7-36 (string "senior")))
|
||||
(e-string @7-39-7-50
|
||||
(e-literal @7-40-7-49 (string "fullstack"))))))
|
||||
(field (name "permissions")
|
||||
(e-list @8-22-8-42 (elem-var 130)
|
||||
(elems
|
||||
(e-tag @8-23-8-27 (ext-var 0) (name "Read") (args "TODO"))
|
||||
(e-tag @8-29-8-34 (ext-var 0) (name "Write") (args "TODO"))
|
||||
(e-tag @8-36-8-41 (ext-var 0) (name "Admin") (args "TODO")))))))))
|
||||
(field (name "callback")
|
||||
(e-lambda @10-15-10-25
|
||||
(args
|
||||
(p-assign @10-16-10-17 (ident "x") (id 138)))
|
||||
(e-binop @10-19-10-25 (op "add")
|
||||
(e-lookup-local @10-19-10-20
|
||||
(pattern (id 138)))
|
||||
(e-int @10-23-10-24 (num-var 142) (sign-needed "false") (bits-needed "7") (value "1")))))
|
||||
(field (name "nested")
|
||||
(e-record @11-13-14-6 (record-var 183) (ext-var 0)
|
||||
(fields
|
||||
(field (name "items")
|
||||
(e-list @12-16-12-52 (elem-var 158)
|
||||
(elems
|
||||
(e-call @12-17-12-30
|
||||
(e-tag @12-17-12-21 (ext-var 0) (name "Some") (args "TODO"))
|
||||
(e-string @12-22-12-29
|
||||
(e-literal @12-23-12-28 (string "first"))))
|
||||
(e-tag @12-32-12-36 (ext-var 0) (name "None") (args "TODO"))
|
||||
(e-call @12-38-12-51
|
||||
(e-tag @12-38-12-42 (ext-var 0) (name "Some") (args "TODO"))
|
||||
(e-string @12-43-12-50
|
||||
(e-literal @12-44-12-49 (string "third")))))))
|
||||
(field (name "result")
|
||||
(e-call @13-17-13-70
|
||||
(e-tag @13-17-13-24 (ext-var 0) (name "Success") (args "TODO"))
|
||||
(e-record @13-25-13-69 (record-var 178) (ext-var 0)
|
||||
(fields
|
||||
(field (name "data")
|
||||
(e-list @13-33-13-42 (elem-var 172)
|
||||
(elems
|
||||
(e-int @13-34-13-35 (num-var 165) (sign-needed "false") (bits-needed "7") (value "1"))
|
||||
(e-int @13-37-13-38 (num-var 168) (sign-needed "false") (bits-needed "7") (value "2"))
|
||||
(e-int @13-40-13-41 (num-var 171) (sign-needed "false") (bits-needed "7") (value "3")))))
|
||||
(field (name "timestamp")
|
||||
(e-string @13-55-13-67
|
||||
(e-literal @13-56-13-66 (string "2024-01-01")))))))))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr (id 189) (type "*"))
|
||||
|
|
|
@ -31,6 +31,22 @@ LowerIdent(1:1-1:7),OpAssign(1:8-1:9),OpenCurly(1:10-1:11),LowerIdent(1:12-1:16)
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(s-let @1-1-1-64 (id 86)
|
||||
(p-assign @1-1-1-7 (ident "person") (id 72))
|
||||
(e-record @1-10-1-64 (record-var 83) (ext-var 0) (id 85)
|
||||
(fields
|
||||
(field (name "name")
|
||||
(e-string @1-18-1-25
|
||||
(e-literal @1-19-1-24 (string "Alice"))))
|
||||
(field (name "age")
|
||||
(e-int @1-32-1-34 (num-var 78) (sign-needed "false") (bits-needed "7") (value "30")))
|
||||
(field (name "email")
|
||||
(e-string @1-43-1-62
|
||||
(e-literal @1-44-1-61 (string "alice@example.com"))))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -121,6 +121,10 @@ OpenCurly(1:1-1:2),LowerIdent(1:3-1:7),Comma(1:7-1:8),LowerIdent(1:9-1:12),Comma
|
|||
~~~roc
|
||||
nameageemailperson
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir (empty true))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -30,6 +30,9 @@ process_user! : { name : Str, age : U32, ..a } => Str
|
|||
```
|
||||
|
||||
|
||||
**MALFORMED TYPE**
|
||||
This type annotation is malformed or contains invalid syntax.
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
LowerIdent(1:1-1:14),OpColon(1:15-1:16),OpenCurly(1:17-1:18),LowerIdent(1:19-1:23),OpColon(1:24-1:25),UpperIdent(1:26-1:29),Comma(1:29-1:30),LowerIdent(1:31-1:34),OpColon(1:35-1:36),UpperIdent(1:37-1:40),Comma(1:40-1:41),DoubleDot(1:42-1:44),LowerIdent(1:44-1:45),CloseCurly(1:46-1:47),OpFatArrow(1:48-1:50),UpperIdent(1:51-1:54),EndOfFile(1:54-1:54),
|
||||
|
@ -49,6 +52,18 @@ LowerIdent(1:1-1:14),OpColon(1:15-1:16),OpenCurly(1:17-1:18),LowerIdent(1:19-1:2
|
|||
~~~roc
|
||||
process_user! : { name : Str, age : } => Str
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(s-type-anno @1-1-1-54 (name "process_user!") (id 80)
|
||||
(ty-fn @1-17-1-54 (effectful true)
|
||||
(ty-record @1-17-1-47
|
||||
(field (field "name")
|
||||
(ty @1-26-1-29 (name "Str")))
|
||||
(field (field "age")
|
||||
(ty-malformed @1-37-1-47)))
|
||||
(ty @1-51-1-54 (name "Str")))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -33,6 +33,23 @@ LowerIdent(1:1-1:13),OpColon(1:14-1:15),UpperIdent(1:16-1:19),Comma(1:19-1:20),U
|
|||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(s-type-anno @1-1-1-78 (name "create_user!") (id 84)
|
||||
(ty-fn @1-16-1-78 (effectful true)
|
||||
(ty @1-16-1-19 (name "Str"))
|
||||
(ty @1-21-1-24 (name "U32"))
|
||||
(ty-record @1-28-1-78
|
||||
(field (field "name")
|
||||
(ty @1-37-1-40 (name "Str")))
|
||||
(field (field "age")
|
||||
(ty @1-48-1-51 (name "U32")))
|
||||
(field (field "id")
|
||||
(ty @1-58-1-61 (name "U64")))
|
||||
(field (field "active")
|
||||
(ty @1-72-1-76 (name "Bool")))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -41,6 +41,9 @@ process_user! : { name : Str, age : U32, .. } => Str
|
|||
```
|
||||
|
||||
|
||||
**MALFORMED TYPE**
|
||||
This type annotation is malformed or contains invalid syntax.
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
LowerIdent(1:1-1:14),OpColon(1:15-1:16),OpenCurly(1:17-1:18),LowerIdent(1:19-1:23),OpColon(1:24-1:25),UpperIdent(1:26-1:29),Comma(1:29-1:30),LowerIdent(1:31-1:34),OpColon(1:35-1:36),UpperIdent(1:37-1:40),Comma(1:40-1:41),DoubleDot(1:42-1:44),CloseCurly(1:45-1:46),OpFatArrow(1:47-1:49),UpperIdent(1:50-1:53),EndOfFile(1:53-1:53),
|
||||
|
@ -54,6 +57,12 @@ LowerIdent(1:1-1:14),OpColon(1:15-1:16),OpenCurly(1:17-1:18),LowerIdent(1:19-1:2
|
|||
~~~roc
|
||||
process_user! :
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(s-type-anno @1-1-1-53 (name "process_user!") (id 74)
|
||||
(ty-malformed @1-47-1-53)))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
|
@ -33,6 +33,24 @@ LowerIdent(1:1-1:15),OpColon(1:16-1:17),OpenCurly(1:18-1:19),LowerIdent(1:20-1:2
|
|||
~~~roc
|
||||
process_things : { name : Str, age : U32, thing : a }, (a -> Str) -> Str
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(s-type-anno @1-1-1-72 (name "process_things") (id 87)
|
||||
(ty-fn @1-18-1-72 (effectful false)
|
||||
(ty-record @1-18-1-53
|
||||
(field (field "name")
|
||||
(ty @1-27-1-30 (name "Str")))
|
||||
(field (field "age")
|
||||
(ty @1-38-1-41 (name "U32")))
|
||||
(field (field "thing")
|
||||
(ty-var @1-50-1-51 (name "a"))))
|
||||
(ty-parens @1-55-1-65
|
||||
(ty-fn @1-56-1-64 (effectful false)
|
||||
(ty-var @1-56-1-57 (name "a"))
|
||||
(ty @1-61-1-64 (name "Str"))))
|
||||
(ty @1-69-1-72 (name "Str")))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
|
|
31
src/snapshots/static_dispatch_super_test.md
generated
31
src/snapshots/static_dispatch_super_test.md
generated
|
@ -18,23 +18,20 @@ LowerIdent(1:1-1:8),NoSpaceOpenRound(1:8-1:9),LowerIdent(1:9-1:13),CloseRound(1:
|
|||
# PARSE
|
||||
~~~clojure
|
||||
(e-field-access @1-1-1-86
|
||||
(e-binop @1-1-1-86 (op "some_fn")
|
||||
(e-field-access @1-1-1-85
|
||||
(e-binop @1-1-1-85 (op "some_fn")
|
||||
(e-field-access @1-1-1-69
|
||||
(e-binop @1-1-1-69 (op "some_fn")
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @1-15-1-41
|
||||
(e-apply @1-15-1-40
|
||||
(e-ident @1-15-1-38 (qaul "") (raw ".static_dispatch_method"))))))
|
||||
(e-question-suffix @1-41-1-72
|
||||
(e-apply @1-41-1-71
|
||||
(e-ident @1-41-1-69 (qaul "") (raw ".next_static_dispatch_method"))))))
|
||||
(e-question-suffix @1-72-1-86
|
||||
(e-ident @1-72-1-85 (qaul "") (raw ".record_field")))))
|
||||
(e-field-access @1-1-1-85
|
||||
(e-field-access @1-1-1-69
|
||||
(e-question-suffix @1-1-1-15
|
||||
(e-apply @1-1-1-14
|
||||
(e-ident @1-1-1-8 (qaul "") (raw "some_fn"))
|
||||
(e-ident @1-9-1-13 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @1-15-1-41
|
||||
(e-apply @1-15-1-40
|
||||
(e-ident @1-15-1-38 (qaul "") (raw ".static_dispatch_method")))))
|
||||
(e-question-suffix @1-41-1-72
|
||||
(e-apply @1-41-1-71
|
||||
(e-ident @1-41-1-69 (qaul "") (raw ".next_static_dispatch_method")))))
|
||||
(e-question-suffix @1-72-1-86
|
||||
(e-ident @1-72-1-85 (qaul "") (raw ".record_field"))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
31
src/snapshots/syntax_grab_bag.md
generated
31
src/snapshots/syntax_grab_bag.md
generated
|
@ -1159,23 +1159,20 @@ CloseCurly(207:1-207:2),EndOfFile(207:2-207:2),
|
|||
(s-decl @189-2-190-8
|
||||
(p-ident @189-2-189-23 (raw "static_dispatch_style"))
|
||||
(e-field-access @189-26-190-8
|
||||
(e-binop @189-26-190-8 (op " This is a module comment!")
|
||||
(e-field-access @189-26-189-110
|
||||
(e-binop @189-26-189-110 (op " This is a module comment!")
|
||||
(e-field-access @189-26-189-94
|
||||
(e-binop @189-26-189-94 (op " This is a module comment!")
|
||||
(e-question-suffix @189-26-189-40
|
||||
(e-apply @189-26-189-39
|
||||
(e-ident @189-26-189-33 (qaul "") (raw "some_fn"))
|
||||
(e-ident @189-34-189-38 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @189-40-189-66
|
||||
(e-apply @189-40-189-65
|
||||
(e-ident @189-40-189-63 (qaul "") (raw ".static_dispatch_method"))))))
|
||||
(e-question-suffix @189-66-189-97
|
||||
(e-apply @189-66-189-96
|
||||
(e-ident @189-66-189-94 (qaul "") (raw ".next_static_dispatch_method"))))))
|
||||
(e-question-suffix @189-97-189-111
|
||||
(e-ident @189-97-189-110 (qaul "") (raw ".record_field"))))))
|
||||
(e-field-access @189-26-189-110
|
||||
(e-field-access @189-26-189-94
|
||||
(e-question-suffix @189-26-189-40
|
||||
(e-apply @189-26-189-39
|
||||
(e-ident @189-26-189-33 (qaul "") (raw "some_fn"))
|
||||
(e-ident @189-34-189-38 (qaul "") (raw "arg1"))))
|
||||
(e-question-suffix @189-40-189-66
|
||||
(e-apply @189-40-189-65
|
||||
(e-ident @189-40-189-63 (qaul "") (raw ".static_dispatch_method")))))
|
||||
(e-question-suffix @189-66-189-97
|
||||
(e-apply @189-66-189-96
|
||||
(e-ident @189-66-189-94 (qaul "") (raw ".next_static_dispatch_method")))))
|
||||
(e-question-suffix @189-97-189-111
|
||||
(e-ident @189-97-189-110 (qaul "") (raw ".record_field")))))
|
||||
(e-question-suffix @190-2-190-29
|
||||
(e-apply @190-2-190-28
|
||||
(e-ident @190-2-190-14 (qaul "Stdout") (raw ".line!"))
|
||||
|
|
15
src/snapshots/type_app_multiple_args.md
generated
15
src/snapshots/type_app_multiple_args.md
generated
|
@ -63,14 +63,13 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(e-apply @6-13-6-55
|
||||
(e-ident @6-13-6-24 (qaul "") (raw "processDict"))
|
||||
(e-field-access @6-25-6-55
|
||||
(e-binop @6-25-6-55 (op "app")
|
||||
(e-apply @6-25-6-37
|
||||
(e-ident @6-25-6-35 (qaul "Dict") (raw ".empty")))
|
||||
(e-apply @6-37-6-54
|
||||
(e-ident @6-37-6-44 (qaul "") (raw ".insert"))
|
||||
(e-string @6-45-6-50
|
||||
(e-string-part @6-46-6-49 (raw "one")))
|
||||
(e-int @6-52-6-53 (raw "1"))))))))))
|
||||
(e-apply @6-25-6-37
|
||||
(e-ident @6-25-6-35 (qaul "Dict") (raw ".empty")))
|
||||
(e-apply @6-37-6-54
|
||||
(e-ident @6-37-6-44 (qaul "") (raw ".insert"))
|
||||
(e-string @6-45-6-50
|
||||
(e-string-part @6-46-6-49 (raw "one")))
|
||||
(e-int @6-52-6-53 (raw "1")))))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
|
|
7
src/snapshots/type_app_single_arg.md
generated
7
src/snapshots/type_app_single_arg.md
generated
|
@ -49,10 +49,9 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(args
|
||||
(p-ident @4-16-4-20 (raw "list")))
|
||||
(e-field-access @4-22-6-6
|
||||
(e-binop @4-22-6-6 (op "app")
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-32
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".len")))))))
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-32
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".len"))))))
|
||||
(s-decl @6-1-6-39
|
||||
(p-ident @6-1-6-6 (raw "main!"))
|
||||
(e-lambda @6-9-6-39
|
||||
|
|
9
src/snapshots/type_app_with_vars.md
generated
9
src/snapshots/type_app_with_vars.md
generated
|
@ -55,11 +55,10 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(p-ident @4-12-4-16 (raw "list"))
|
||||
(p-ident @4-18-4-20 (raw "fn")))
|
||||
(e-field-access @4-22-6-6
|
||||
(e-binop @4-22-6-6 (op "app")
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-34
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".map"))
|
||||
(e-ident @4-31-4-33 (qaul "") (raw "fn")))))))
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-34
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".map"))
|
||||
(e-ident @4-31-4-33 (qaul "") (raw "fn"))))))
|
||||
(s-decl @6-1-6-33
|
||||
(p-ident @6-1-6-6 (raw "main!"))
|
||||
(e-lambda @6-9-6-33
|
||||
|
|
7
src/snapshots/type_application_basic.md
generated
7
src/snapshots/type_application_basic.md
generated
|
@ -49,10 +49,9 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(args
|
||||
(p-ident @4-16-4-20 (raw "list")))
|
||||
(e-field-access @4-22-6-6
|
||||
(e-binop @4-22-6-6 (op "app")
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-32
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".len")))))))
|
||||
(e-ident @4-22-4-26 (qaul "") (raw "list"))
|
||||
(e-apply @4-26-4-32
|
||||
(e-ident @4-26-4-30 (qaul "") (raw ".len"))))))
|
||||
(s-decl @6-1-6-47
|
||||
(p-ident @6-1-6-6 (raw "main!"))
|
||||
(e-lambda @6-9-6-47
|
||||
|
|
5
src/snapshots/type_multiple_aliases.md
generated
5
src/snapshots/type_multiple_aliases.md
generated
|
@ -140,9 +140,8 @@ CloseCurly(17:1-17:2),EndOfFile(17:2-17:2),
|
|||
(args
|
||||
(p-ident @12-16-12-20 (raw "user")))
|
||||
(e-field-access @12-22-14-6
|
||||
(e-binop @12-22-14-6 (op "app")
|
||||
(e-ident @12-22-12-26 (qaul "") (raw "user"))
|
||||
(e-ident @12-26-12-31 (qaul "") (raw ".name"))))))
|
||||
(e-ident @12-22-12-26 (qaul "") (raw "user"))
|
||||
(e-ident @12-26-12-31 (qaul "") (raw ".name")))))
|
||||
(s-decl @14-1-17-2
|
||||
(p-ident @14-1-14-6 (raw "main!"))
|
||||
(e-lambda @14-9-17-2
|
||||
|
|
5
src/snapshots/type_record_simple.md
generated
5
src/snapshots/type_record_simple.md
generated
|
@ -51,9 +51,8 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(args
|
||||
(p-ident @4-12-4-18 (raw "person")))
|
||||
(e-field-access @4-20-6-6
|
||||
(e-binop @4-20-6-6 (op "app")
|
||||
(e-ident @4-20-4-26 (qaul "") (raw "person"))
|
||||
(e-ident @4-26-4-31 (qaul "") (raw ".name"))))))
|
||||
(e-ident @4-20-4-26 (qaul "") (raw "person"))
|
||||
(e-ident @4-26-4-31 (qaul "") (raw ".name")))))
|
||||
(s-decl @6-1-6-15
|
||||
(p-ident @6-1-6-6 (raw "main!"))
|
||||
(e-lambda @6-9-6-15
|
||||
|
|
38
src/snapshots/type_record_with_vars.md
generated
38
src/snapshots/type_record_with_vars.md
generated
|
@ -13,18 +13,7 @@ getField = |record| record.field
|
|||
main! = |_| {}
|
||||
~~~
|
||||
# PROBLEMS
|
||||
**UNDECLARED TYPE VARIABLE**
|
||||
The type variable ``b`` is not declared in this scope.
|
||||
|
||||
Type variables must be introduced in a type annotation before they can be used.
|
||||
|
||||
This type variable is referenced here:
|
||||
**type_record_with_vars.md:3:31:3:32:**
|
||||
```roc
|
||||
getField : { field: a, other: b } -> a
|
||||
```
|
||||
|
||||
|
||||
NIL
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwApp(1:1-1:4),OpenSquare(1:5-1:6),LowerIdent(1:6-1:11),CloseSquare(1:11-1:12),OpenCurly(1:13-1:14),LowerIdent(1:15-1:17),OpColon(1:17-1:18),KwPlatform(1:19-1:27),StringStart(1:28-1:29),StringPart(1:29-1:50),StringEnd(1:50-1:51),CloseCurly(1:52-1:53),Newline(1:1-1:1),
|
||||
|
@ -62,9 +51,8 @@ LowerIdent(6:1-6:6),OpAssign(6:7-6:8),OpBar(6:9-6:10),Underscore(6:10-6:11),OpBa
|
|||
(args
|
||||
(p-ident @4-13-4-19 (raw "record")))
|
||||
(e-field-access @4-21-6-6
|
||||
(e-binop @4-21-6-6 (op "app")
|
||||
(e-ident @4-21-4-27 (qaul "") (raw "record"))
|
||||
(e-ident @4-27-4-33 (qaul "") (raw ".field"))))))
|
||||
(e-ident @4-21-4-27 (qaul "") (raw "record"))
|
||||
(e-ident @4-27-4-33 (qaul "") (raw ".field")))))
|
||||
(s-decl @6-1-6-15
|
||||
(p-ident @6-1-6-6 (raw "main!"))
|
||||
(e-lambda @6-9-6-15
|
||||
|
@ -84,16 +72,16 @@ main! = |_| {}
|
|||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(d-let (id 92)
|
||||
(p-assign @4-1-4-9 (ident "getField") (id 81))
|
||||
(e-lambda @4-12-6-6 (id 85)
|
||||
(d-let (id 93)
|
||||
(p-assign @4-1-4-9 (ident "getField") (id 82))
|
||||
(e-lambda @4-12-6-6 (id 86)
|
||||
(args
|
||||
(p-assign @4-13-4-19 (ident "record") (id 82)))
|
||||
(p-assign @4-13-4-19 (ident "record") (id 83)))
|
||||
(e-dot-access @4-21-6-6 (field "field")
|
||||
(receiver
|
||||
(e-lookup-local @4-21-4-27
|
||||
(pattern (id 82))))))
|
||||
(annotation @4-1-4-9 (signature 90) (id 91)
|
||||
(pattern (id 83))))))
|
||||
(annotation @4-1-4-9 (signature 91) (id 92)
|
||||
(declared-type
|
||||
(ty-fn @3-12-3-39 (effectful false)
|
||||
(ty-record @3-12-3-34
|
||||
|
@ -102,11 +90,11 @@ main! = |_| {}
|
|||
(field (field "other")
|
||||
(ty-var @3-31-3-32 (name "b"))))
|
||||
(ty-var @3-38-3-39 (name "a"))))))
|
||||
(d-let (id 97)
|
||||
(p-assign @6-1-6-6 (ident "main!") (id 93))
|
||||
(e-lambda @6-9-6-15 (id 96)
|
||||
(d-let (id 98)
|
||||
(p-assign @6-1-6-6 (ident "main!") (id 94))
|
||||
(e-lambda @6-9-6-15 (id 97)
|
||||
(args
|
||||
(p-underscore @6-10-6-11 (id 94)))
|
||||
(p-underscore @6-10-6-11 (id 95)))
|
||||
(e-empty_record @6-13-6-15))))
|
||||
~~~
|
||||
# TYPES
|
||||
|
|
34
src/snapshots/type_var_namespace.md
generated
34
src/snapshots/type_var_namespace.md
generated
|
@ -34,18 +34,6 @@ Here is the problematic code:
|
|||
```
|
||||
|
||||
|
||||
**UNDECLARED TYPE VARIABLE**
|
||||
The type variable ``elem`` is not declared in this scope.
|
||||
|
||||
Type variables must be introduced in a type annotation before they can be used.
|
||||
|
||||
This type variable is referenced here:
|
||||
**type_var_namespace.md:10:14:10:18:**
|
||||
```roc
|
||||
result : elem
|
||||
```
|
||||
|
||||
|
||||
**UNDEFINED VARIABLE**
|
||||
Nothing is named `first` in this scope.
|
||||
Is there an `import` or `exposing` missing up-top?
|
||||
|
@ -146,18 +134,20 @@ main! = |_| {}
|
|||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(d-let (id 109)
|
||||
(d-let (id 110)
|
||||
(p-assign @5-1-5-8 (ident "process") (id 78))
|
||||
(e-lambda @5-11-14-2 (id 102)
|
||||
(e-lambda @5-11-14-2 (id 103)
|
||||
(args
|
||||
(p-assign @5-12-5-16 (ident "list") (id 79)))
|
||||
(e-block @5-18-14-2
|
||||
(s-let @7-5-7-14
|
||||
(p-assign @7-5-7-9 (ident "elem") (id 80))
|
||||
(e-int @7-12-7-14 (num-var 83) (sign-needed "false") (bits-needed "7") (value "42") (id 83)))
|
||||
(s-type-anno @10-5-11-11 (name "result")
|
||||
(ty-var @10-14-10-18 (name "elem")))
|
||||
(s-let @11-5-11-30
|
||||
(p-assign @11-5-11-11 (ident "result") (id 89))
|
||||
(e-call @11-14-11-30 (id 93)
|
||||
(p-assign @11-5-11-11 (ident "result") (id 90))
|
||||
(e-call @11-14-11-30 (id 94)
|
||||
(e-runtime-error (tag "ident_not_in_scope"))
|
||||
(e-lookup-local @11-25-11-29
|
||||
(pattern (id 79)))))
|
||||
|
@ -167,18 +157,18 @@ main! = |_| {}
|
|||
(e-lookup-local @11-53-11-57
|
||||
(pattern (id 80)))))
|
||||
(e-lookup-local @13-5-13-11
|
||||
(pattern (id 89)))))
|
||||
(annotation @5-1-5-8 (signature 107) (id 108)
|
||||
(pattern (id 90)))))
|
||||
(annotation @5-1-5-8 (signature 108) (id 109)
|
||||
(declared-type
|
||||
(ty-fn @4-11-4-29 (effectful false)
|
||||
(ty-apply @4-11-4-21 (symbol "List")
|
||||
(ty-var @4-16-4-20 (name "elem")))
|
||||
(ty-var @4-25-4-29 (name "elem"))))))
|
||||
(d-let (id 114)
|
||||
(p-assign @16-1-16-6 (ident "main!") (id 110))
|
||||
(e-lambda @16-9-16-15 (id 113)
|
||||
(d-let (id 115)
|
||||
(p-assign @16-1-16-6 (ident "main!") (id 111))
|
||||
(e-lambda @16-9-16-15 (id 114)
|
||||
(args
|
||||
(p-underscore @16-10-16-11 (id 111)))
|
||||
(p-underscore @16-10-16-11 (id 112)))
|
||||
(e-empty_record @16-13-16-15))))
|
||||
~~~
|
||||
# TYPES
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue