mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-22 01:21:46 +00:00
Fix some incorrect error messages
This commit is contained in:
parent
cc597648a0
commit
0bd77fe6af
25 changed files with 277 additions and 104 deletions
|
@ -1540,16 +1540,15 @@ fn checkBinopExpr(self: *Self, expr_idx: CIR.Expr.Idx, expr_region: Region, bino
|
|||
const rhs_var = @as(Var, @enumFromInt(@intFromEnum(binop.rhs)));
|
||||
const result_var = @as(Var, @enumFromInt(@intFromEnum(expr_idx)));
|
||||
|
||||
// Create a fresh number variable for the operation
|
||||
// Create a SINGLE fresh number variable for the operation
|
||||
// All operands and the result must be the same numeric type
|
||||
const num_content = Content{ .structure = .{ .num = .{ .num_unbound = .{ .sign_needed = false, .bits_needed = 0 } } } };
|
||||
const num_var_lhs = try self.freshFromContent(num_content, expr_region);
|
||||
const num_var_rhs = try self.freshFromContent(num_content, expr_region);
|
||||
const num_var_result = try self.freshFromContent(num_content, expr_region);
|
||||
const num_var = try self.freshFromContent(num_content, expr_region);
|
||||
|
||||
// Unify lhs, rhs, and result with the number type
|
||||
_ = try self.unify(num_var_lhs, lhs_var);
|
||||
_ = try self.unify(num_var_rhs, rhs_var);
|
||||
_ = try self.unify(result_var, num_var_result);
|
||||
// Unify lhs, rhs, and result with the SAME number type
|
||||
_ = try self.unify(num_var, lhs_var);
|
||||
_ = try self.unify(num_var, rhs_var);
|
||||
_ = try self.unify(num_var, result_var);
|
||||
|
||||
return does_fx;
|
||||
},
|
||||
|
|
|
@ -320,7 +320,11 @@ pub const ReportBuilder = struct {
|
|||
try snapshot_writer.write(types.expected_snapshot);
|
||||
const owned_expected = try report.addOwnedString(self.buf.items[0..]);
|
||||
|
||||
const region = self.can_ir.store.regions.get(@enumFromInt(@intFromEnum(types.actual_var)));
|
||||
// For annotation mismatches, we want to highlight the expression that doesn't match,
|
||||
// not the annotation itself. When from_annotation is true and we're showing
|
||||
// "The type annotation says...", the expression is in expected_var.
|
||||
const region_var = if (types.from_annotation) types.expected_var else types.actual_var;
|
||||
const region = self.can_ir.store.regions.get(@enumFromInt(@intFromEnum(region_var)));
|
||||
|
||||
// Add source region highlighting
|
||||
const region_info = self.module_env.calcRegionInfo(region.*);
|
||||
|
@ -1252,12 +1256,14 @@ pub const ReportBuilder = struct {
|
|||
try appendOrdinal(&self.buf, data.second_arg_index + 1);
|
||||
const second_arg_index = try report.addOwnedString(self.buf.items);
|
||||
|
||||
// The types from unification already have the correct snapshots
|
||||
// expected = first argument, actual = second argument
|
||||
self.buf.clearRetainingCapacity();
|
||||
try snapshot_writer.write(types.actual_snapshot);
|
||||
try snapshot_writer.write(types.expected_snapshot);
|
||||
const first_type = try report.addOwnedString(self.buf.items);
|
||||
|
||||
self.buf.clearRetainingCapacity();
|
||||
try snapshot_writer.write(types.expected_snapshot);
|
||||
try snapshot_writer.write(types.actual_snapshot);
|
||||
const second_type = try report.addOwnedString(self.buf.items);
|
||||
|
||||
try report.document.addText("The ");
|
||||
|
|
|
@ -61,7 +61,7 @@ add2 = x + 2
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @3.1-3.5 (type "Num(_size)")))
|
||||
(patt @3.1-3.5 (type "Error")))
|
||||
(expressions
|
||||
(expr @3.8-3.18 (type "Num(_size)"))))
|
||||
(expr @3.8-3.18 (type "Error"))))
|
||||
~~~
|
||||
|
|
|
@ -49,10 +49,10 @@ fail_pair_diff_types = mk_pair("1", 2)
|
|||
^^^ ^
|
||||
|
||||
The first argument is of type:
|
||||
_Num(_size)_
|
||||
_Str_
|
||||
|
||||
But the second argument is of type:
|
||||
_Str_
|
||||
_Num(_size)_
|
||||
|
||||
`mk_pair` needs these arguments to have compatible types.
|
||||
|
||||
|
@ -93,10 +93,10 @@ fail_with_implicit = mk_pair_inferred("str", 2)
|
|||
^^^^^ ^
|
||||
|
||||
The first argument is of type:
|
||||
_Num(_size)_
|
||||
_Str_
|
||||
|
||||
But the second argument is of type:
|
||||
_Str_
|
||||
_Num(_size)_
|
||||
|
||||
`mk_pair_inferred` needs these arguments to have compatible types.
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ main! = |_| {
|
|||
~~~
|
||||
# EXPECTED
|
||||
UNUSED VARIABLE - bound_type_var_no_annotation.md:19:5:19:9
|
||||
TYPE MISMATCH - bound_type_var_no_annotation.md:11:18:11:19
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `pair` is not used anywhere in your code.
|
||||
|
@ -46,6 +47,20 @@ The unused variable is declared here:
|
|||
^^^^
|
||||
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**bound_type_var_no_annotation.md:11:18:11:19:**
|
||||
```roc
|
||||
addOne = |n| n + 1
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_U64_
|
||||
|
||||
# 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),
|
||||
|
@ -262,11 +277,11 @@ main! = |_| {
|
|||
(defs
|
||||
(patt @3.1-3.9 (type "_arg -> _ret"))
|
||||
(patt @7.1-7.8 (type "a, b -> (a, b)"))
|
||||
(patt @11.1-11.7 (type "U64 -> U64"))
|
||||
(patt @13.1-13.6 (type "_arg -> U64")))
|
||||
(patt @11.1-11.7 (type "Error -> Error"))
|
||||
(patt @13.1-13.6 (type "_arg -> Error")))
|
||||
(expressions
|
||||
(expr @3.12-3.17 (type "_arg -> _ret"))
|
||||
(expr @7.11-7.42 (type "a, b -> (a, b)"))
|
||||
(expr @11.10-11.19 (type "U64 -> U64"))
|
||||
(expr @13.9-25.2 (type "_arg -> U64"))))
|
||||
(expr @11.10-11.19 (type "Error -> Error"))
|
||||
(expr @13.9-25.2 (type "_arg -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -34,7 +34,7 @@ main! = |_| {
|
|||
UNUSED VARIABLE - crash_and_ellipsis_test.md:20:5:20:12
|
||||
UNUSED VARIABLE - crash_and_ellipsis_test.md:21:5:21:12
|
||||
UNUSED VARIABLE - crash_and_ellipsis_test.md:22:5:22:12
|
||||
TYPE MISMATCH - crash_and_ellipsis_test.md:8:20:8:23
|
||||
TYPE MISMATCH - crash_and_ellipsis_test.md:9:17:11:2
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `result1` is not used anywhere in your code.
|
||||
|
@ -74,11 +74,12 @@ The unused variable is declared here:
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**crash_and_ellipsis_test.md:8:20:8:23:**
|
||||
**crash_and_ellipsis_test.md:9:17:11:2:**
|
||||
```roc
|
||||
testCrash : U64 -> U64
|
||||
testCrash = |_| {
|
||||
crash "This is a crash message"
|
||||
}
|
||||
```
|
||||
^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_U64_
|
||||
|
|
|
@ -41,7 +41,7 @@ PARSE ERROR - fuzz_crash_025.md:14:48:14:49
|
|||
PARSE ERROR - fuzz_crash_025.md:15:1:15:2
|
||||
PARSE ERROR - fuzz_crash_025.md:15:3:15:4
|
||||
PARSE ERROR - fuzz_crash_025.md:15:4:15:5
|
||||
TYPE MISMATCH - fuzz_crash_025.md:13:5:13:9
|
||||
TYPE MISMATCH - fuzz_crash_025.md:14:5:14:48
|
||||
# PROBLEMS
|
||||
**PARSE ERROR**
|
||||
Type applications require parentheses around their type arguments.
|
||||
|
@ -153,11 +153,11 @@ f =8
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**fuzz_crash_025.md:13:5:13:9:**
|
||||
**fuzz_crash_025.md:14:5:14:48:**
|
||||
```roc
|
||||
e : U128
|
||||
e = 3402823669209384634633746074317682114553.14: I8
|
||||
```
|
||||
^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_U128_
|
||||
|
|
|
@ -227,7 +227,7 @@ UNDECLARED TYPE - fuzz_crash_027.md:153:9:153:14
|
|||
INVALID IF CONDITION - fuzz_crash_027.md:50:5:50:5
|
||||
INCOMPATIBLE MATCH PATTERNS - fuzz_crash_027.md:64:2:64:2
|
||||
TYPE MISMATCH - fuzz_crash_027.md:111:2:113:3
|
||||
TYPE MISMATCH - fuzz_crash_027.md:99:9:99:38
|
||||
TYPE MISMATCH - fuzz_crash_027.md:100:9:148:2
|
||||
# PROBLEMS
|
||||
**LEADING ZERO**
|
||||
Numbers cannot have leading zeros.
|
||||
|
@ -920,11 +920,58 @@ But you are trying to use it as:
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**fuzz_crash_027.md:99:9:99:38:**
|
||||
**fuzz_crash_027.md:100:9:148:2:**
|
||||
```roc
|
||||
main! : List(String) -> Result({}, _)
|
||||
main! = |_| { # Yeah Ie
|
||||
world = "World"
|
||||
var number = 123
|
||||
expect blah == 1
|
||||
tag = Blue
|
||||
return # Comd
|
||||
tag
|
||||
|
||||
# Jusnt!
|
||||
|
||||
...
|
||||
match_time(
|
||||
..., #
|
||||
)
|
||||
some_func(
|
||||
dbg # bug
|
||||
42, # Aft expr
|
||||
)
|
||||
crash "Unreachtement
|
||||
tag_with = Ok(number)
|
||||
ited = "Hello, ${world}"
|
||||
list = [
|
||||
add_one(
|
||||
dbg # Afin list
|
||||
e[, # afarg
|
||||
), 456, # ee
|
||||
]
|
||||
for n in list {
|
||||
line!("Adding ${n} to ${number}")
|
||||
number = number + n
|
||||
}
|
||||
record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned }
|
||||
tuple = (123, "World", tag, Ok(world), (nested, tuple), [1, 2, 3])
|
||||
m_tuple = (
|
||||
123,
|
||||
"World",
|
||||
tag1,
|
||||
Ok(world), # Thisnt
|
||||
(nested, tuple),
|
||||
[1, 2, 3],
|
||||
)
|
||||
bsult = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5
|
||||
stale = some_fn(arg1)?.statod()?.ned()?.recd?
|
||||
Stdoline!(
|
||||
"How about ${ #
|
||||
Num.toStr(number) # on expr
|
||||
} as a",
|
||||
)
|
||||
} # Commenl decl
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_List(Error) -> Result({ }, _d)_
|
||||
|
|
|
@ -23,7 +23,7 @@ goodValue = "test"
|
|||
~~~
|
||||
# EXPECTED
|
||||
UNDERSCORE IN TYPE ALIAS - underscore_error_propagation.md:1:1:1:1
|
||||
TYPE MISMATCH - underscore_error_propagation.md:14:13:14:24
|
||||
TYPE MISMATCH - underscore_error_propagation.md:15:13:15:19
|
||||
# PROBLEMS
|
||||
**UNDERSCORE IN TYPE ALIAS**
|
||||
Underscores are not allowed in type alias declarations.
|
||||
|
@ -38,11 +38,11 @@ Underscores in type annotations mean "I don't care about this type", which doesn
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**underscore_error_propagation.md:14:13:14:24:**
|
||||
**underscore_error_propagation.md:15:13:15:19:**
|
||||
```roc
|
||||
goodValue : GoodDerived
|
||||
goodValue = "test"
|
||||
```
|
||||
^^^^^^^^^^^
|
||||
^^^^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_GoodDerived_
|
||||
|
|
|
@ -17,6 +17,7 @@ wrong_type_function = |x| x * 3.14
|
|||
~~~
|
||||
# EXPECTED
|
||||
TYPE MISMATCH - lambda_annotation_mismatch_error.md:5:23:5:24
|
||||
TYPE MISMATCH - lambda_annotation_mismatch_error.md:9:31:9:35
|
||||
# PROBLEMS
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
|
@ -32,6 +33,20 @@ It is of type:
|
|||
But you are trying to use it as:
|
||||
_Num(_size)_
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**lambda_annotation_mismatch_error.md:9:31:9:35:**
|
||||
```roc
|
||||
wrong_type_function = |x| x * 3.14
|
||||
```
|
||||
^^^^
|
||||
|
||||
It is of type:
|
||||
_Frac(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_I64_
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwModule(1:1-1:7),OpenSquare(1:8-1:9),LowerIdent(1:9-1:24),Comma(1:24-1:25),LowerIdent(1:26-1:45),CloseSquare(1:45-1:46),
|
||||
|
@ -116,8 +131,8 @@ NO CHANGE
|
|||
(inferred-types
|
||||
(defs
|
||||
(patt @5.1-5.16 (type "Error -> Error"))
|
||||
(patt @9.1-9.20 (type "I64 -> I64")))
|
||||
(patt @9.1-9.20 (type "Error -> Error")))
|
||||
(expressions
|
||||
(expr @5.19-5.29 (type "Error -> Error"))
|
||||
(expr @9.23-9.35 (type "I64 -> I64"))))
|
||||
(expr @9.23-9.35 (type "Error -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -72,5 +72,5 @@ NO CHANGE
|
|||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr @1.1-1.14 (type "Num(_size) -> _arg -> Num(_size2)"))
|
||||
(expr @1.1-1.14 (type "Error -> _arg -> Error"))
|
||||
~~~
|
||||
|
|
|
@ -79,10 +79,10 @@ The first and third arguments to `multi_arg_fn` must have compatible types, but
|
|||
^^^^^^^
|
||||
|
||||
The first argument is of type:
|
||||
_Str_
|
||||
_Num(_size)_
|
||||
|
||||
But the third argument is of type:
|
||||
_Num(_size)_
|
||||
_Str_
|
||||
|
||||
`multi_arg_fn` needs these arguments to have compatible types.
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ main! = |_| {
|
|||
# EXPECTED
|
||||
UNUSED VARIABLE - lambda_parameter_unused.md:5:8:5:14
|
||||
UNDERSCORE VARIABLE USED - lambda_parameter_unused.md:9:22:9:29
|
||||
TYPE MISMATCH - lambda_parameter_unused.md:9:32:9:33
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `unused` is not used anywhere in your code.
|
||||
|
@ -59,6 +60,20 @@ multiply = |_factor| _factor * 2
|
|||
^^^^^^^
|
||||
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**lambda_parameter_unused.md:9:32:9:33:**
|
||||
```roc
|
||||
multiply = |_factor| _factor * 2
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_U64_
|
||||
|
||||
# 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),
|
||||
|
@ -305,15 +320,15 @@ main! = |_| {
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @5.1-5.4 (type "U64 -> U64"))
|
||||
(patt @9.1-9.9 (type "U64 -> U64"))
|
||||
(patt @13.1-13.8 (type "U64 -> U64"))
|
||||
(patt @17.1-17.7 (type "U64 -> U64"))
|
||||
(patt @19.1-19.6 (type "_arg -> Num(_size)")))
|
||||
(patt @5.1-5.4 (type "Error -> Error"))
|
||||
(patt @9.1-9.9 (type "Error -> Error"))
|
||||
(patt @13.1-13.8 (type "Error -> Error"))
|
||||
(patt @17.1-17.7 (type "Error -> Error"))
|
||||
(patt @19.1-19.6 (type "_arg -> Error")))
|
||||
(expressions
|
||||
(expr @5.7-5.18 (type "U64 -> U64"))
|
||||
(expr @9.12-9.33 (type "U64 -> U64"))
|
||||
(expr @13.11-13.23 (type "U64 -> U64"))
|
||||
(expr @17.10-17.27 (type "U64 -> U64"))
|
||||
(expr @19.9-25.2 (type "_arg -> Num(_size)"))))
|
||||
(expr @5.7-5.18 (type "Error -> Error"))
|
||||
(expr @9.12-9.33 (type "Error -> Error"))
|
||||
(expr @13.11-13.23 (type "Error -> Error"))
|
||||
(expr @17.10-17.27 (type "Error -> Error"))
|
||||
(expr @19.9-25.2 (type "_arg -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -14,9 +14,22 @@ main : I64, I64 -> I64
|
|||
main = |_, _| helper(5)
|
||||
~~~
|
||||
# EXPECTED
|
||||
NIL
|
||||
TYPE MISMATCH - lambda_ret_constraint_bug.md:4:18:4:19
|
||||
# PROBLEMS
|
||||
NIL
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**lambda_ret_constraint_bug.md:4:18:4:19:**
|
||||
```roc
|
||||
helper = |n| n * 2
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_I64_
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwApp(1:1-1:4),OpenSquare(1:5-1:6),LowerIdent(1:6-1:10),CloseSquare(1:10-1:11),OpenCurly(1:12-1:13),LowerIdent(1:14-1:16),OpColon(1:16-1:17),KwPlatform(1:18-1:26),StringStart(1:27-1:28),StringPart(1:28-1:45),StringEnd(1:45-1:46),CloseCurly(1:47-1:48),
|
||||
|
@ -112,9 +125,9 @@ NO CHANGE
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @4.1-4.7 (type "I64 -> I64"))
|
||||
(patt @7.1-7.5 (type "I64, I64 -> I64")))
|
||||
(patt @4.1-4.7 (type "Error -> Error"))
|
||||
(patt @7.1-7.5 (type "Error, Error -> Error")))
|
||||
(expressions
|
||||
(expr @4.10-4.19 (type "I64 -> I64"))
|
||||
(expr @7.8-7.24 (type "I64, I64 -> I64"))))
|
||||
(expr @4.10-4.19 (type "Error -> Error"))
|
||||
(expr @7.8-7.24 (type "Error, Error -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -1083,7 +1083,7 @@ main = |_| {
|
|||
(patt @85.1-85.9 (type "Num(_size)"))
|
||||
(patt @86.1-86.9 (type "List(Num(_size))"))
|
||||
(patt @87.1-87.9 (type "{ base: Num(_size), derived: List(Num(_size2)) }"))
|
||||
(patt @90.1-90.6 (type "{ numbers: { value: Num(_size), list: List(Num(_size2)), float: Frac(_size3) }, strings: { value: Str, list: List(Str) }, empty_lists: { raw: List(Num(_size4)), in_list: List(List(Num(_size5))), in_record: { data: List(Num(_size6)) } }, computations: { from_num: Num(_size7), from_frac: Num(_size8), list_from_num: List(Num(_size9)) } }"))
|
||||
(patt @90.1-90.6 (type "{ numbers: { value: Num(_size), list: List(Num(_size2)), float: Frac(_size3) }, strings: { value: Str, list: List(Str) }, empty_lists: { raw: List(Num(_size4)), in_list: List(List(Num(_size5))), in_record: { data: List(Num(_size6)) } }, computations: { from_num: Num(_size7), from_frac: Frac(_size8), list_from_num: List(Num(_size9)) } }"))
|
||||
(patt @105.1-105.5 (type "_arg -> Num(_size)")))
|
||||
(expressions
|
||||
(expr @4.7-4.9 (type "Num(_size)"))
|
||||
|
@ -1112,6 +1112,6 @@ main = |_| {
|
|||
(expr @85.12-85.19 (type "Num(_size)"))
|
||||
(expr @86.12-86.22 (type "List(Num(_size))"))
|
||||
(expr @87.12-87.59 (type "{ base: Num(_size), derived: List(Num(_size2)) }"))
|
||||
(expr @90.9-103.2 (type "{ numbers: { value: Num(_size), list: List(Num(_size2)), float: Frac(_size3) }, strings: { value: Str, list: List(Str) }, empty_lists: { raw: List(Num(_size4)), in_list: List(List(Num(_size5))), in_record: { data: List(Num(_size6)) } }, computations: { from_num: Num(_size7), from_frac: Num(_size8), list_from_num: List(Num(_size9)) } }"))
|
||||
(expr @90.9-103.2 (type "{ numbers: { value: Num(_size), list: List(Num(_size2)), float: Frac(_size3) }, strings: { value: Str, list: List(Str) }, empty_lists: { raw: List(Num(_size4)), in_list: List(List(Num(_size5))), in_record: { data: List(Num(_size6)) } }, computations: { from_num: Num(_size7), from_frac: Frac(_size8), list_from_num: List(Num(_size9)) } }"))
|
||||
(expr @105.8-108.2 (type "_arg -> Num(_size)"))))
|
||||
~~~
|
||||
|
|
|
@ -247,29 +247,29 @@ main = |_| {
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @4.1-4.4 (type "Num(_size)"))
|
||||
(patt @4.1-4.4 (type "Frac(_size)"))
|
||||
(patt @5.1-5.5 (type "Frac(_size)"))
|
||||
(patt @8.1-8.8 (type "Num(_size)"))
|
||||
(patt @8.1-8.8 (type "Frac(_size)"))
|
||||
(patt @9.1-9.10 (type "Frac(_size)"))
|
||||
(patt @12.1-12.8 (type "Num(_size)"))
|
||||
(patt @13.1-13.13 (type "Num(_size)"))
|
||||
(patt @16.1-16.10 (type "Num(_size)"))
|
||||
(patt @17.1-17.15 (type "Num(_size)"))
|
||||
(patt @12.1-12.8 (type "Frac(_size)"))
|
||||
(patt @13.1-13.13 (type "Frac(_size)"))
|
||||
(patt @16.1-16.10 (type "Frac(_size)"))
|
||||
(patt @17.1-17.15 (type "Frac(_size)"))
|
||||
(patt @20.1-20.7 (type "Num(_size) -> Num(_size2)"))
|
||||
(patt @23.1-23.12 (type "Num(_size)"))
|
||||
(patt @24.1-24.14 (type "Num(_size)"))
|
||||
(patt @26.1-26.5 (type "_arg -> Num(_size)")))
|
||||
(patt @24.1-24.14 (type "Frac(_size)"))
|
||||
(patt @26.1-26.5 (type "_arg -> Frac(_size)")))
|
||||
(expressions
|
||||
(expr @4.7-4.9 (type "Num(_size)"))
|
||||
(expr @4.7-4.9 (type "Frac(_size)"))
|
||||
(expr @5.8-5.11 (type "Frac(_size)"))
|
||||
(expr @8.11-8.14 (type "Num(_size)"))
|
||||
(expr @8.11-8.14 (type "Frac(_size)"))
|
||||
(expr @9.13-9.17 (type "Frac(_size)"))
|
||||
(expr @12.11-12.19 (type "Num(_size)"))
|
||||
(expr @13.16-13.23 (type "Num(_size)"))
|
||||
(expr @16.13-16.23 (type "Num(_size)"))
|
||||
(expr @17.18-17.27 (type "Num(_size)"))
|
||||
(expr @12.11-12.19 (type "Frac(_size)"))
|
||||
(expr @13.16-13.23 (type "Frac(_size)"))
|
||||
(expr @16.13-16.23 (type "Frac(_size)"))
|
||||
(expr @17.18-17.27 (type "Frac(_size)"))
|
||||
(expr @20.10-20.19 (type "Num(_size) -> Num(_size2)"))
|
||||
(expr @23.15-23.24 (type "Num(_size)"))
|
||||
(expr @24.17-24.28 (type "Num(_size)"))
|
||||
(expr @26.8-29.2 (type "_arg -> Num(_size)"))))
|
||||
(expr @24.17-24.28 (type "Frac(_size)"))
|
||||
(expr @26.8-29.2 (type "_arg -> Frac(_size)"))))
|
||||
~~~
|
||||
|
|
|
@ -65,5 +65,5 @@ match value {
|
|||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr @1.1-3.2 (type "Num(_size)"))
|
||||
(expr @1.1-3.2 (type "Error"))
|
||||
~~~
|
||||
|
|
|
@ -115,5 +115,5 @@ match shape {
|
|||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr @1.1-5.2 (type "Num(_size)"))
|
||||
(expr @1.1-5.2 (type "Frac(_size)"))
|
||||
~~~
|
||||
|
|
|
@ -111,5 +111,5 @@ match (value, other) {
|
|||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(expr @1.1-4.2 (type "Num(_size)"))
|
||||
(expr @1.1-4.2 (type "Error"))
|
||||
~~~
|
||||
|
|
|
@ -81,7 +81,7 @@ is_named_color = |str|{
|
|||
UNUSED VARIABLE - Color.md:30:5:30:25
|
||||
UNDEFINED VARIABLE - Color.md:68:14:68:27
|
||||
INVALID NOMINAL TAG - Color.md:23:5:23:33
|
||||
TYPE MISMATCH - Color.md:26:7:26:46
|
||||
TYPE MISMATCH - Color.md:27:7:46:2
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `is_char_in_hex_range` is not used anywhere in your code.
|
||||
|
@ -115,7 +115,7 @@ I'm having trouble with this nominal tag:
|
|||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The tag is:
|
||||
_RGBA(U8, U8, U8, Num(_size))_
|
||||
_RGBA(U8, U8, U8, Frac(_size))_
|
||||
|
||||
But it should be one of:
|
||||
_[Hex(Str), Named(Str), RGB(U8, U8, U8), RGBA(U8, U8, U8, Dec)]_
|
||||
|
@ -126,11 +126,29 @@ But it should be one of:
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**Color.md:26:7:26:46:**
|
||||
**Color.md:27:7:46:2:**
|
||||
```roc
|
||||
hex : Str -> Result(Color, [InvalidHex(Str)])
|
||||
hex = |str| {
|
||||
|
||||
bytes = str.to_utf8()
|
||||
is_char_in_hex_range = |b| (b >= '0' and b <= '9') or (b >= 'a' and b <= 'f') or (b >= 'A' and b <= 'F')
|
||||
|
||||
match bytes {
|
||||
['#', a, b, c, d, e, f] => {
|
||||
is_valid =
|
||||
a.is_char_in_hex_range()
|
||||
and b.is_char_in_hex_range()
|
||||
and c.is_char_in_hex_range()
|
||||
and d.is_char_in_hex_range()
|
||||
and e.is_char_in_hex_range()
|
||||
and f.is_char_in_hex_range()
|
||||
|
||||
if is_valid Ok(Color.Hex(str)) else Err(InvalidHex("Expected Hex to be in the range 0-9, a-f, A-F, got ${str}"))
|
||||
}
|
||||
_ => Err(InvalidHex("Expected Hex must start with # and be 7 characters long, got ${str}"))
|
||||
}
|
||||
}
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_Str -> Result(Error, [InvalidHex(Str)])_
|
||||
|
|
|
@ -16,8 +16,23 @@ addTwoF64 : F64 -> F64
|
|||
addTwoF64 = |x| x + 2.0
|
||||
~~~
|
||||
# EXPECTED
|
||||
TYPE MISMATCH - simple_lambda_constraint_success.md:5:18:5:19
|
||||
TYPE MISMATCH - simple_lambda_constraint_success.md:9:17:9:18
|
||||
# PROBLEMS
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**simple_lambda_constraint_success.md:5:18:5:19:**
|
||||
```roc
|
||||
addTwo = |x| x + 2
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_I64_
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**simple_lambda_constraint_success.md:9:17:9:18:**
|
||||
|
@ -115,9 +130,9 @@ NO CHANGE
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @5.1-5.7 (type "I64 -> I64"))
|
||||
(patt @5.1-5.7 (type "Error -> Error"))
|
||||
(patt @9.1-9.10 (type "Error -> Error")))
|
||||
(expressions
|
||||
(expr @5.10-5.19 (type "I64 -> I64"))
|
||||
(expr @5.10-5.19 (type "Error -> Error"))
|
||||
(expr @9.13-9.24 (type "Error -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -14,9 +14,22 @@ my_number : U64
|
|||
my_number = add_one(42)
|
||||
~~~
|
||||
# EXPECTED
|
||||
NIL
|
||||
TYPE MISMATCH - type_anno_connection.md:4:19:4:20
|
||||
# PROBLEMS
|
||||
NIL
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**type_anno_connection.md:4:19:4:20:**
|
||||
```roc
|
||||
add_one = |x| x + 1
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_U64_
|
||||
|
||||
# TOKENS
|
||||
~~~zig
|
||||
KwModule(1:1-1:7),OpenSquare(1:8-1:9),LowerIdent(1:9-1:16),Comma(1:16-1:17),LowerIdent(1:18-1:27),CloseSquare(1:27-1:28),
|
||||
|
@ -90,9 +103,9 @@ NO CHANGE
|
|||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt @4.1-4.8 (type "U64 -> U64"))
|
||||
(patt @7.1-7.10 (type "U64")))
|
||||
(patt @4.1-4.8 (type "Error -> Error"))
|
||||
(patt @7.1-7.10 (type "Error")))
|
||||
(expressions
|
||||
(expr @4.11-4.20 (type "U64 -> U64"))
|
||||
(expr @7.13-7.24 (type "U64"))))
|
||||
(expr @4.11-4.20 (type "Error -> Error"))
|
||||
(expr @7.13-7.24 (type "Error"))))
|
||||
~~~
|
||||
|
|
|
@ -35,6 +35,7 @@ main! = |_| {
|
|||
~~~
|
||||
# EXPECTED
|
||||
UNUSED VARIABLE - type_annotation_basic.md:21:5:21:9
|
||||
TYPE MISMATCH - type_annotation_basic.md:13:18:13:19
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `pair` is not used anywhere in your code.
|
||||
|
@ -48,6 +49,20 @@ The unused variable is declared here:
|
|||
^^^^
|
||||
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**type_annotation_basic.md:13:18:13:19:**
|
||||
```roc
|
||||
addOne = |n| n + 1
|
||||
```
|
||||
^
|
||||
|
||||
It is of type:
|
||||
_Num(_size)_
|
||||
|
||||
But you are trying to use it as:
|
||||
_U64_
|
||||
|
||||
# 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),
|
||||
|
@ -276,11 +291,11 @@ main! = |_| {
|
|||
(defs
|
||||
(patt @5.1-5.9 (type "a -> a"))
|
||||
(patt @9.1-9.8 (type "a, b -> (a, b)"))
|
||||
(patt @13.1-13.7 (type "U64 -> U64"))
|
||||
(patt @15.1-15.6 (type "_arg -> U64")))
|
||||
(patt @13.1-13.7 (type "Error -> Error"))
|
||||
(patt @15.1-15.6 (type "_arg -> Error")))
|
||||
(expressions
|
||||
(expr @5.12-5.17 (type "a -> a"))
|
||||
(expr @9.11-9.42 (type "a, b -> (a, b)"))
|
||||
(expr @13.10-13.19 (type "U64 -> U64"))
|
||||
(expr @15.9-27.2 (type "_arg -> U64"))))
|
||||
(expr @13.10-13.19 (type "Error -> Error"))
|
||||
(expr @15.9-27.2 (type "_arg -> Error"))))
|
||||
~~~
|
||||
|
|
|
@ -33,7 +33,7 @@ UNDECLARED TYPE - type_app_complex_nested.md:4:30:4:35
|
|||
UNDECLARED TYPE - type_app_complex_nested.md:4:51:4:56
|
||||
UNUSED VARIABLE - type_app_complex_nested.md:7:12:7:21
|
||||
UNDECLARED TYPE - type_app_complex_nested.md:12:14:12:19
|
||||
TYPE MISMATCH - type_app_complex_nested.md:12:55:12:56
|
||||
TYPE MISMATCH - type_app_complex_nested.md:13:18:15:2
|
||||
# PROBLEMS
|
||||
**UNDECLARED TYPE**
|
||||
The type _Maybe_ is not declared in this scope.
|
||||
|
@ -104,11 +104,12 @@ deepNested : Maybe(Result(List(Dict(Str, a)), _b)) -> a
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**type_app_complex_nested.md:12:55:12:56:**
|
||||
**type_app_complex_nested.md:13:18:15:2:**
|
||||
```roc
|
||||
deepNested : Maybe(Result(List(Dict(Str, a)), _b)) -> a
|
||||
deepNested = |_| {
|
||||
crash "not implemented"
|
||||
}
|
||||
```
|
||||
^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_a_
|
||||
|
|
|
@ -34,7 +34,7 @@ UNUSED VARIABLE - type_var_underscore_conventions.md:9:22:9:26
|
|||
UNUSED VARIABLE - type_var_underscore_conventions.md:13:17:13:18
|
||||
UNUSED VARIABLE - type_var_underscore_conventions.md:17:17:17:18
|
||||
UNUSED VARIABLE - type_var_underscore_conventions.md:22:9:22:10
|
||||
TYPE MISMATCH - type_var_underscore_conventions.md:8:36:8:41
|
||||
TYPE MISMATCH - type_var_underscore_conventions.md:9:28:9:37
|
||||
# PROBLEMS
|
||||
**UNUSED VARIABLE**
|
||||
Variable `x` is not used anywhere in your code.
|
||||
|
@ -98,11 +98,11 @@ main = |x| "done"
|
|||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
**type_var_underscore_conventions.md:8:36:8:41:**
|
||||
**type_var_underscore_conventions.md:9:28:9:37:**
|
||||
```roc
|
||||
ending_underscore : List(elem_) -> elem_
|
||||
ending_underscore = |list| "default"
|
||||
```
|
||||
^^^^^
|
||||
^^^^^^^^^
|
||||
|
||||
The type annotation says it should have the type:
|
||||
_elem__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue