Work on error messages

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-18 09:59:36 +01:00
parent 7f7bf5c98d
commit 42698bb219
13 changed files with 333 additions and 160 deletions

View file

@ -2,7 +2,7 @@
source: tests/file_tests.rs
expression: parsed
info:
input: "{{ if }} {{ end }}\n{{ if if }} {{ end }}\n{{ if if }} {{ for foo in bar }} {{ end }} {{ end }}\n{{ for in bar }} {{ end }}\n{{ for blah bar }} {{ end }}\n{{ else }}"
input: "{{ if }} {{ end }}\n{{ if if }} {{ end }}\n{{ if if }} {{ for foo in bar }} {{ end }} {{ end }}\n{{ for in bar }} {{ end }}\n{{ for blah bar }} {{ end }}\n{{ for blah}} {{ end }}\n{{ else }}"
context: {}
---
ParsedTemplate {
@ -99,8 +99,21 @@ ParsedTemplate {
[Whitespace]"\n" (149..150),
[LeftDelim]"{{" (150..152),
[Whitespace]" " (152..153),
[ConditionalElse]"else" (153..157),
[Whitespace]" " (157..158),
[RightDelim]"}}" (158..160),
[For]"for" (153..156),
[Whitespace]" " (156..157),
[Ident]"blah" (157..161),
[RightDelim]"}}" (161..163),
[Whitespace]" " (163..164),
[LeftDelim]"{{" (164..166),
[Whitespace]" " (166..167),
[End]"end" (167..170),
[Whitespace]" " (170..171),
[RightDelim]"}}" (171..173),
[Whitespace]"\n" (173..174),
[LeftDelim]"{{" (174..176),
[Whitespace]" " (176..177),
[ConditionalElse]"else" (177..181),
[Whitespace]" " (181..182),
[RightDelim]"}}" (182..184),
],
}

View file

@ -2,31 +2,50 @@
source: tests/file_tests.rs
expression: ast
info:
input: "{{ if }} {{ end }}\n{{ if if }} {{ end }}\n{{ if if }} {{ for foo in bar }} {{ end }} {{ end }}\n{{ for in bar }} {{ end }}\n{{ for blah bar }} {{ end }}\n{{ else }}"
input: "{{ if }} {{ end }}\n{{ if if }} {{ end }}\n{{ if if }} {{ for foo in bar }} {{ end }} {{ end }}\n{{ for in bar }} {{ end }}\n{{ for blah bar }} {{ end }}\n{{ for blah}} {{ end }}\n{{ else }}"
context: {}
---
error: Expected an expression after 'if'
 ╭▸ 
1 │ {{ if }} {{ end }}
 ━━
╰╴
╰╴ ━━
error: Expected an expression after 'if'
 ╭▸ 
2 │ {{ if if }} {{ end }}
╰╴ ━━
error: Expected an expression after 'if'
 ╭▸ 
3 │ {{ if if }} {{ for foo in bar }} {{ end }} {{ end }}
╰╴ ━━
error: Expected identifier here
error: Missing ident here
 ╭▸ 
4 │ {{ for in bar }} {{ end }}
╰╴ ━━━━━━
error: Missing `in` in `for _ in <expr>`
error: Missing `in` in `for .. in ` loop
 ╭▸ 
5 │ {{ for blah bar }} {{ end }}
╰╴ ━━━━━━━━
error: An error occurred while producing an Ast
│ ━━━━━━━━
╰╴
note: Try adding it
╭╴
5 │ {{ for blah in bar }} {{ end }}
╰╴ ++
error: Missing `in` in `for .. in ` loop
 ╭▸ 
6 │ {{ else }}
╰╴ ━━━━━━━
6 │ {{ for blah}} {{ end }}
│ ━━━━
╰╴
note: Try adding it
╭╴
6 │ {{ for blah in}} {{ end }}
╰╴ ++
error: Unexpected keyword
 ╭▸ 
7 │ {{ else }}
╰╴ ━━━━

View file

@ -5,4 +5,5 @@
{{ if if }} {{ for foo in bar }} {{ end }} {{ end }}
{{ for in bar }} {{ end }}
{{ for blah bar }} {{ end }}
{{ for blah}} {{ end }}
{{ else }}