Merge pull request #7858 from roc-lang/err-reporting

Report for `expected_colon_after_type_annotation`
This commit is contained in:
Luke Boswell 2025-06-23 21:06:22 +10:00 committed by GitHub
commit 58bccb3ed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 370 additions and 15 deletions

View file

@ -360,6 +360,36 @@ pub fn parseDiagnosticToReport(self: *AST, diagnostic: Diagnostic, allocator: st
try report.document.addText("For example: ");
try report.document.addCodeBlock("[1, 2, 3]");
},
.expected_colon_after_type_annotation => {
try report.document.addReflowingText("Type applications require parentheses around their type arguments.");
try report.document.addLineBreak();
try report.document.addLineBreak();
try report.document.addReflowingText("I found a type followed by what looks like a type argument, but they need to be connected with parentheses.");
try report.document.addLineBreak();
try report.document.addLineBreak();
try report.document.addText("Instead of:");
try report.document.addLineBreak();
try report.document.addIndent(1);
try report.document.addAnnotated("List U8", .error_highlight);
try report.document.addLineBreak();
try report.document.addLineBreak();
try report.document.addText("Use:");
try report.document.addLineBreak();
try report.document.addIndent(1);
try report.document.addAnnotated("List(U8)", .emphasized);
try report.document.addLineBreak();
try report.document.addLineBreak();
try report.document.addText("Other valid examples:");
try report.document.addLineBreak();
try report.document.addIndent(1);
try report.document.addAnnotated("Dict(Str, Num)", .dimmed);
try report.document.addLineBreak();
try report.document.addIndent(1);
try report.document.addAnnotated("Result(a, Str)", .dimmed);
try report.document.addLineBreak();
try report.document.addIndent(1);
try report.document.addAnnotated("Maybe(List(U64))", .dimmed);
},
else => {
const tag_name = @tagName(diagnostic.tag);
const owned_tag = try report.addOwnedString(tag_name);
@ -371,7 +401,7 @@ pub fn parseDiagnosticToReport(self: *AST, diagnostic: Diagnostic, allocator: st
}
// Add source context if we have a valid region
if (region.start.offset < region.end.offset and region.end.offset <= self.source.len) {
if (region.start.offset <= region.end.offset and region.end.offset <= self.source.len) {
// Compute line_starts from source for proper region info calculation
var line_starts = std.ArrayList(u32).init(allocator);
defer line_starts.deinit();
@ -388,6 +418,7 @@ pub fn parseDiagnosticToReport(self: *AST, diagnostic: Diagnostic, allocator: st
return report; // Return report without source context if region calculation fails
};
try report.document.addLineBreak();
try report.document.addLineBreak();
try report.document.addText("Here is the problematic code:");
try report.document.addLineBreak();

View file

@ -147,10 +147,10 @@ pub fn pushMalformed(self: *Parser, comptime t: type, tag: AST.Diagnostic.Tag, s
self.advanceOne(); // TODO: find a better point to advance to
}
// Create a diagnostic region that points to the current problematic token
// Ensure the region is always valid by using min/max
const diagnostic_start = @min(pos, self.pos);
const diagnostic_end = @max(pos, self.pos);
// Create a diagnostic region that points to the problematic token
// If the parser has moved too far from the start, use the start token for better error location
const diagnostic_start = if (self.pos > start and (self.pos - start) > 2) start else @min(pos, self.pos);
const diagnostic_end = if (self.pos > start and (self.pos - start) > 2) start + 1 else @max(pos, self.pos);
// If start equals end, make it a single-token region
const diagnostic_region = AST.TokenizedRegion{ .start = diagnostic_start, .end = if (diagnostic_start == diagnostic_end) diagnostic_start + 1 else diagnostic_end };

View file

@ -14,6 +14,7 @@ var topLevelVar_ = 0
**PARSE ERROR**
A parsing error occurred: `var_only_allowed_in_a_body`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**can_var_scoping_invalid_top_level.md:4:1:4:17:**
```roc

View file

@ -29,6 +29,7 @@ main! = |_|
**UNEXPECTED TOKEN IN EXPRESSION**
The token **crash "** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**crash_and_ellipsis_test.md:9:17:9:24:**
```roc
@ -39,6 +40,7 @@ testCrash = |_| crash "This is a crash message"
**UNEXPECTED TOKEN IN EXPRESSION**
The token **crash "** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**crash_and_ellipsis_test.md:13:23:13:30:**
```roc
@ -49,6 +51,7 @@ testCrashSimple = |_| crash "oops"
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= testEllipsis** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**crash_and_ellipsis_test.md:16:13:16:27:**
```roc

View file

@ -11,6 +11,7 @@ type=expr
**PARSE ERROR**
A parsing error occurred: `expr_no_space_dot_int`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**float_invalid.md:1:5:1:8:**
```roc

View file

@ -11,6 +11,7 @@ type=expr
**UNEXPECTED TOKEN IN EXPRESSION**
The token **& age** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**record_field_update.md:1:10:1:15:**
```roc
@ -21,6 +22,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN TYPE ANNOTATION**
The token **31 }** is not expected in a type annotation.
Type annotations should contain types like _Str_, _Num a_, or _List U64_.
Here is the problematic code:
**record_field_update.md:1:17:1:21:**
```roc

View file

@ -29,6 +29,7 @@ type=expr
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**tuple_patterns.md:4:12:4:15:**
```roc
@ -39,6 +40,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**tuple_patterns.md:7:22:7:25:**
```roc
@ -49,6 +51,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**tuple_patterns.md:10:28:10:31:**
```roc
@ -59,6 +62,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**tuple_patterns.md:13:29:13:32:**
```roc
@ -69,6 +73,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**tuple_patterns.md:16:19:16:22:**
```roc

View file

@ -11,6 +11,7 @@ type=expr
**UNEXPECTED TOKEN IN EXPRESSION**
The token **!isValid** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**unary_op_not.md:1:1:1:9:**
```roc

View file

@ -11,6 +11,7 @@ type=expr
**UNEXPECTED TOKEN IN EXPRESSION**
The token **+ 2** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**unknown_operator.md:1:4:1:7:**
```roc

View file

@ -13,6 +13,7 @@ foo = if tru then 0
**PARSE ERROR**
A parsing error occurred: `no_else`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**expr_if_missing_else.md:3:19:3:20:**
```roc

View file

@ -13,6 +13,7 @@ foo = asd.0
**PARSE ERROR**
A parsing error occurred: `expr_no_space_dot_int`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**expr_no_space_dot_int.md:3:10:3:12:**
```roc

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_001.md:1:1:1:4:**
```roc
@ -25,6 +26,7 @@ mo|%
**UNEXPECTED TOKEN IN PATTERN**
The token **%** is not expected in a pattern.
Patterns can contain identifiers, literals, lists, records, or tags.
Here is the problematic code:
**fuzz_crash_001.md:1:4:1:5:**
```roc
@ -36,6 +38,13 @@ mo|%
A parsing error occurred: `expected_expr_bar`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_001.md:1:5:1:5:**
```roc
mo|%
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_002.md:1:1:1:6:**
```roc
@ -25,6 +26,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **:;** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:5:1:7:**
```roc
@ -35,6 +37,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **;:** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:6:1:8:**
```roc
@ -45,6 +48,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:7:1:9:**
```roc
@ -55,6 +59,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:8:1:10:**
```roc
@ -65,6 +70,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:9:1:11:**
```roc
@ -75,6 +81,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:10:1:12:**
```roc
@ -85,6 +92,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:11:1:13:**
```roc
@ -95,6 +103,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:12:1:14:**
```roc
@ -105,6 +114,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:13:1:15:**
```roc
@ -115,6 +125,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:14:1:16:**
```roc
@ -125,6 +136,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:15:1:17:**
```roc
@ -135,6 +147,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:16:1:18:**
```roc
@ -145,6 +158,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:17:1:19:**
```roc
@ -155,6 +169,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:18:1:20:**
```roc
@ -165,6 +180,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **::** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:19:1:21:**
```roc
@ -175,6 +191,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **:le** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:20:1:23:**
```roc
@ -185,6 +202,7 @@ modu:;::::::::::::::le[%
**UNEXPECTED TOKEN IN EXPRESSION**
The token **%** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_002.md:1:24:1:25:**
```roc
@ -197,6 +215,13 @@ This list is missing a closing bracket or has a syntax error.
Lists must be closed with **]** and list items must be separated by commas.
For example: [1, 2, 3]
Here is the problematic code:
**fuzz_crash_002.md:1:25:1:25:**
```roc
modu:;::::::::::::::le[%
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -18,6 +18,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_003.md:1:1:1:4:**
```roc

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_004.md:1:1:1:2:**
```roc

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_005.md:1:1:1:5:**
```roc

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_007.md:1:1:1:6:**
```roc
@ -25,6 +26,7 @@ ff8.8.d
**UNEXPECTED TOKEN IN EXPRESSION**
The token **.8.d** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_007.md:1:4:1:8:**
```roc
@ -35,6 +37,7 @@ ff8.8.d
**UNEXPECTED TOKEN IN EXPRESSION**
The token **.d** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_007.md:1:6:1:8:**
```roc

View file

@ -18,6 +18,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_008.md:1:1:1:4:**
```roc
@ -29,6 +30,13 @@ Here is the problematic code:
A parsing error occurred: `expected_expr_bar`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_008.md:1:5:1:5:**
```roc
||1
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -26,6 +26,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_009.md:1:2:1:4:**
```roc

View file

@ -28,6 +28,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_010.md:1:1:1:3:**
```roc

View file

@ -14,6 +14,7 @@ There are too many closing braces here.
**PARSE ERROR**
A parsing error occurred: `header_expected_open_square`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_011.md:1:8:1:11:**
```roc
@ -22,8 +23,27 @@ module P]F
**PARSE ERROR**
A parsing error occurred: `expected_colon_after_type_annotation`
This is an unexpected parsing error. Please check your syntax.
Type applications require parentheses around their type arguments.
I found a type followed by what looks like a type argument, but they need to be connected with parentheses.
Instead of:
**List U8**
Use:
**List(U8)**
Other valid examples:
`Dict(Str, Num)`
`Result(a, Str)`
`Maybe(List(U64))`
Here is the problematic code:
**fuzz_crash_011.md:1:11:1:11:**
```roc
module P]F
```
# TOKENS
~~~zig

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_012.md:1:1:1:3:**
```roc
@ -25,6 +26,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN PATTERN**
The token **|(** is not expected in a pattern.
Patterns can contain identifiers, literals, lists, records, or tags.
Here is the problematic code:
**fuzz_crash_012.md:1:4:1:6:**
```roc
@ -33,13 +35,27 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN PATTERN**
The token is not expected in a pattern.
The token **(|** is not expected in a pattern.
Patterns can contain identifiers, literals, lists, records, or tags.
Here is the problematic code:
**fuzz_crash_012.md:1:3:1:5:**
```roc
||(|(l888888888|
```
**PARSE ERROR**
A parsing error occurred: `expected_expr_bar`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_012.md:1:17:1:17:**
```roc
||(|(l888888888|
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_013.md:1:1:1:3:**
```roc

View file

@ -17,6 +17,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_014.md:1:1:1:5:**
```roc
@ -28,13 +29,28 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_014.md:1:3:1:3:**
```roc
0b.0
```
**UNEXPECTED TOKEN IN EXPRESSION**
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_014.md:2:1:2:1:**
```roc
0bu22
```
**UNEXPECTED TOKEN IN EXPRESSION**
The token **0u22** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_014.md:3:1:3:5:**
```roc

View file

@ -21,6 +21,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_015.md:1:1:1:6:**
```roc
@ -32,10 +33,24 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_015.md:1:4:1:4:**
```roc
0o0.0
```
**PARSE ERROR**
A parsing error occurred: `expr_no_space_dot_int`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_015.md:3:4:3:4:**
```roc
0u8.0
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_016.md:1:1:1:3:**
```roc
@ -26,6 +27,13 @@ Here is the problematic code:
A parsing error occurred: `expected_expr_bar`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_016.md:1:3:1:3:**
```roc
0|
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -16,6 +16,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_017.md:1:1:1:5:**
```roc
@ -26,6 +27,7 @@ me = "luc"
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= "** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**fuzz_crash_017.md:1:4:1:7:**
```roc
@ -37,6 +39,13 @@ me = "luc"
A parsing error occurred: `string_expected_close_interpolation`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_crash_017.md:2:7:2:14:**
```roc
foo = "hello ${namF
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -16,6 +16,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_crash_018.md:1:1:1:4:**
```roc

View file

@ -15,6 +15,7 @@ For example:
module [main]
or for an app:
app [main!] { pf: platform "../basic-cli/platform.roc" }
Here is the problematic code:
**fuzz_hang_001.md:1:1:1:4:**
```roc
@ -26,6 +27,13 @@ Here is the problematic code:
A parsing error occurred: `expected_expr_close_round_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**fuzz_hang_001.md:1:4:1:4:**
```roc
0 (
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -12,6 +12,13 @@ module
A parsing error occurred: `header_expected_open_square`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**header_expected_open_bracket.md:1:7:1:7:**
```roc
module
```
# TOKENS
~~~zig
KwModule(1:1-1:7),EndOfFile(1:7-1:7),

View file

@ -49,6 +49,7 @@ main! = |_| {
**PARSE ERROR**
A parsing error occurred: `expected_expr_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_alias_decl.md:30:5:30:13:**
```roc
@ -59,6 +60,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= 123** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_alias_decl.md:30:12:30:17:**
```roc
@ -69,6 +71,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **}** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_alias_decl.md:39:1:39:2:**
```roc

View file

@ -0,0 +1,64 @@
# META
~~~ini
description=Type annotation missing parentheses for type application
type=file
~~~
# SOURCE
~~~roc
module [nums]
nums : List U8
~~~
# PROBLEMS
**PARSE ERROR**
Type applications require parentheses around their type arguments.
I found a type followed by what looks like a type argument, but they need to be connected with parentheses.
Instead of:
**List U8**
Use:
**List(U8)**
Other valid examples:
`Dict(Str, Num)`
`Result(a, Str)`
`Maybe(List(U64))`
Here is the problematic code:
**type_annotation_missing_parens.md:3:15:3:15:**
```roc
nums : List U8
```
# TOKENS
~~~zig
KwModule(1:1-1:7),OpenSquare(1:8-1:9),LowerIdent(1:9-1:13),CloseSquare(1:13-1:14),Newline(1:1-1:1),
Newline(1:1-1:1),
LowerIdent(3:1-3:5),OpColon(3:6-3:7),UpperIdent(3:8-3:12),UpperIdent(3:13-3:15),EndOfFile(3:15-3:15),
~~~
# PARSE
~~~clojure
(file (1:1-3:15)
(module (1:1-1:14)
(exposes (1:8-1:14) (exposed_item (lower_ident "nums"))))
(statements
(type_anno (3:1-3:15) "nums" (ty "List"))
(malformed_stmt (3:13-3:15) "expected_colon_after_type_annotation")))
~~~
# FORMATTED
~~~roc
module [nums]
nums : List
~~~
# CANONICALIZE
~~~clojure
(can_ir "empty")
~~~
# TYPES
~~~clojure
(inferred_types (defs) (expressions))
~~~

View file

@ -25,10 +25,23 @@ main! = |_| processComplex(Ok([Some(42), None]))
~~~
# PROBLEMS
**PARSE ERROR**
A parsing error occurred: `expected_colon_after_type_annotation`
This is an unexpected parsing error. Please check your syntax.
Type applications require parentheses around their type arguments.
I found a type followed by what looks like a type argument, but they need to be connected with parentheses.
Instead of:
**List U8**
Use:
**List(U8)**
Other valid examples:
`Dict(Str, Num)`
`Result(a, Str)`
`Maybe(List(U64))`
Here is the problematic code:
**type_app_complex_nested.md:7:23:7:27:**
**type_app_complex_nested.md:7:9:7:12:**
```roc
Ok(maybeList) -> []
```
@ -37,6 +50,7 @@ Here is the problematic code:
**PARSE ERROR**
A parsing error occurred: `invalid_type_arg`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_app_complex_nested.md:8:13:8:15:**
```roc
@ -45,10 +59,23 @@ Here is the problematic code:
**PARSE ERROR**
A parsing error occurred: `expected_colon_after_type_annotation`
This is an unexpected parsing error. Please check your syntax.
Type applications require parentheses around their type arguments.
I found a type followed by what looks like a type argument, but they need to be connected with parentheses.
Instead of:
**List U8**
Use:
**List(U8)**
Other valid examples:
`Dict(Str, Num)`
`Result(a, Str)`
`Maybe(List(U64))`
Here is the problematic code:
**type_app_complex_nested.md:8:16:8:20:**
**type_app_complex_nested.md:8:9:8:13:**
```roc
Err(_) -> []
```
@ -57,6 +84,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **crash "** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_app_complex_nested.md:12:18:12:25:**
```roc

View file

@ -16,6 +16,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **, a** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_function_basic.md:3:17:3:20:**
```roc

View file

@ -16,6 +16,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **, a** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_function_effectful.md:3:22:3:25:**
```roc
@ -26,6 +27,7 @@ runEffect! : (a => b), a => b
**UNEXPECTED TOKEN IN EXPRESSION**
The token **=> b** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_function_effectful.md:3:26:3:30:**
```roc

View file

@ -16,6 +16,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **-> (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_function_multi_arg.md:3:21:3:25:**
```roc

View file

@ -16,6 +16,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **, a** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_function_simple.md:3:17:3:20:**
```roc

View file

@ -16,6 +16,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **, (** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_higher_order_multiple_vars.md:3:19:3:22:**
```roc
@ -26,6 +27,7 @@ compose : (b -> c), (a -> b) -> (a -> c)
**PARSE ERROR**
A parsing error occurred: `expr_arrow_expects_ident`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_higher_order_multiple_vars.md:3:33:3:35:**
```roc
@ -37,6 +39,13 @@ compose : (b -> c), (a -> b) -> (a -> c)
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_higher_order_multiple_vars.md:3:40:3:40:**
```roc
compose : (b -> c), (a -> b) -> (a -> c)
```
**INVALID STATEMENT**
The statement **expr** is not allowed at the top level.
Only definitions, type annotations, and imports are allowed at the top level.

View file

@ -21,6 +21,7 @@ main! = |_| {}
**PARSE ERROR**
A parsing error occurred: `expected_expr_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_local_scope_vars.md:6:5:6:12:**
```roc
@ -31,6 +32,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= |** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_local_scope_vars.md:6:11:6:14:**
```roc
@ -42,6 +44,13 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_local_scope_vars.md:9:1:9:1:**
```roc
}
```
**INVALID LAMBDA**
The body of this lambda expression is not valid.

View file

@ -22,8 +22,9 @@ InnerModule : {
**PARSE ERROR**
A parsing error occurred: `expected_type_field_name`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_shadowing_across_scopes.md:11:22:11:31:**
**type_shadowing_across_scopes.md:11:5:11:13:**
```roc
Result : [Success, Failure]
```
@ -32,6 +33,7 @@ Here is the problematic code:
**PARSE ERROR**
A parsing error occurred: `expected_ty_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_shadowing_across_scopes.md:11:24:11:32:**
```roc
@ -43,9 +45,17 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_shadowing_across_scopes.md:11:31:11:31:**
```roc
Result : [Success, Failure]
```
**UNEXPECTED TOKEN IN EXPRESSION**
The token **}** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_shadowing_across_scopes.md:12:1:12:2:**
```roc

View file

@ -20,6 +20,7 @@ main! = |_| {}
**PARSE ERROR**
A parsing error occurred: `expected_expr_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_var_annotation_body_connection.md:6:5:6:12:**
```roc
@ -30,6 +31,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= x** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_annotation_body_connection.md:6:11:6:14:**
```roc
@ -41,6 +43,13 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_annotation_body_connection.md:8:1:8:1:**
```roc
}
```
**INVALID LAMBDA**
The body of this lambda expression is not valid.

View file

@ -20,6 +20,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= pair** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_multiple.md:6:21:6:27:**
```roc

View file

@ -26,6 +26,7 @@ main! = |_| {}
**UNEXPECTED TOKEN IN EXPRESSION**
The token **|> Result** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_namespace.md:11:31:11:40:**
```roc

View file

@ -23,6 +23,7 @@ main! = |_| {}
**PARSE ERROR**
A parsing error occurred: `expected_expr_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_var_shadowing.md:8:5:8:12:**
```roc
@ -33,6 +34,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= |** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_shadowing.md:8:11:8:14:**
```roc
@ -44,6 +46,13 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_shadowing.md:11:1:11:1:**
```roc
}
```
**INVALID LAMBDA**
The body of this lambda expression is not valid.

View file

@ -21,6 +21,7 @@ main! = |_| {}
**PARSE ERROR**
A parsing error occurred: `expected_expr_close_curly_or_comma`
This is an unexpected parsing error. Please check your syntax.
Here is the problematic code:
**type_var_shadowing_inner.md:6:5:6:12:**
```roc
@ -31,6 +32,7 @@ Here is the problematic code:
**UNEXPECTED TOKEN IN EXPRESSION**
The token **= |** is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_shadowing_inner.md:6:11:6:14:**
```roc
@ -42,6 +44,13 @@ Here is the problematic code:
The token is not expected in an expression.
Expressions can be identifiers, literals, function calls, or operators.
Here is the problematic code:
**type_var_shadowing_inner.md:9:1:9:1:**
```roc
}
```
**INVALID LAMBDA**
The body of this lambda expression is not valid.