-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic during malformed empty interpolated string (#333)
Fixes #332
- Loading branch information
1 parent
671a289
commit cdf5614
Showing
8 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/ast.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
source: full-moon/tests/fail_cases.rs | ||
expression: result.ast() | ||
input_file: full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty | ||
--- | ||
nodes: | ||
stmts: | ||
- - FunctionCall: | ||
prefix: | ||
Name: | ||
leading_trivia: [] | ||
token: | ||
start_position: | ||
bytes: 0 | ||
line: 1 | ||
character: 1 | ||
end_position: | ||
bytes: 5 | ||
line: 1 | ||
character: 6 | ||
token_type: | ||
type: Identifier | ||
identifier: print | ||
trailing_trivia: [] | ||
suffixes: | ||
- Call: | ||
AnonymousCall: | ||
Parentheses: | ||
parentheses: | ||
tokens: | ||
- leading_trivia: [] | ||
token: | ||
start_position: | ||
bytes: 5 | ||
line: 1 | ||
character: 6 | ||
end_position: | ||
bytes: 6 | ||
line: 1 | ||
character: 7 | ||
token_type: | ||
type: Symbol | ||
symbol: ( | ||
trailing_trivia: [] | ||
- leading_trivia: [] | ||
token: | ||
start_position: | ||
bytes: 10 | ||
line: 1 | ||
character: 11 | ||
end_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
token_type: | ||
type: Symbol | ||
symbol: ) | ||
trailing_trivia: [] | ||
arguments: | ||
pairs: | ||
- End: | ||
InterpolatedString: | ||
segments: [] | ||
last_string: | ||
leading_trivia: [] | ||
token: | ||
start_position: | ||
bytes: 6 | ||
line: 1 | ||
character: 7 | ||
end_position: | ||
bytes: 8 | ||
line: 1 | ||
character: 9 | ||
token_type: | ||
type: InterpolatedString | ||
literal: "" | ||
kind: Begin | ||
trailing_trivia: [] | ||
- ~ | ||
eof: | ||
leading_trivia: [] | ||
token: | ||
start_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
end_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
token_type: | ||
type: Eof | ||
trailing_trivia: [] |
6 changes: 6 additions & 0 deletions
6
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/ast_to_string.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
source: full-moon/tests/fail_cases.rs | ||
expression: ast.to_string() | ||
input_file: full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty | ||
--- | ||
"print(`{)" |
10 changes: 10 additions & 0 deletions
10
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/error_display.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: full-moon/tests/fail_cases.rs | ||
expression: "String::from_utf8(output.into_inner()).unwrap()" | ||
input_file: full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty | ||
--- | ||
error[ast]: expected expression after `{` | ||
┌─ source.lua:1:7 | ||
│ | ||
1 │ print(`{}`) | ||
│ ^^ |
20 changes: 20 additions & 0 deletions
20
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/errors.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: full-moon/tests/fail_cases.rs | ||
expression: result.errors() | ||
input_file: full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty | ||
--- | ||
- AstError: | ||
token: | ||
start_position: | ||
bytes: 6 | ||
line: 1 | ||
character: 7 | ||
end_position: | ||
bytes: 8 | ||
line: 1 | ||
character: 9 | ||
token_type: | ||
type: InterpolatedString | ||
literal: "" | ||
kind: Begin | ||
additional: "expected expression after `{`" |
1 change: 1 addition & 0 deletions
1
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/source.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print(`{}`) |
72 changes: 72 additions & 0 deletions
72
full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty/tokens.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
source: full-moon/tests/fail_cases.rs | ||
expression: tokens | ||
input_file: full-moon/tests/roblox_cases/fail/parser/string_interpolation_empty | ||
--- | ||
- start_position: | ||
bytes: 0 | ||
line: 1 | ||
character: 1 | ||
end_position: | ||
bytes: 5 | ||
line: 1 | ||
character: 6 | ||
token_type: | ||
type: Identifier | ||
identifier: print | ||
- start_position: | ||
bytes: 5 | ||
line: 1 | ||
character: 6 | ||
end_position: | ||
bytes: 6 | ||
line: 1 | ||
character: 7 | ||
token_type: | ||
type: Symbol | ||
symbol: ( | ||
- start_position: | ||
bytes: 6 | ||
line: 1 | ||
character: 7 | ||
end_position: | ||
bytes: 8 | ||
line: 1 | ||
character: 9 | ||
token_type: | ||
type: InterpolatedString | ||
literal: "" | ||
kind: Begin | ||
- start_position: | ||
bytes: 8 | ||
line: 1 | ||
character: 9 | ||
end_position: | ||
bytes: 10 | ||
line: 1 | ||
character: 11 | ||
token_type: | ||
type: InterpolatedString | ||
literal: "" | ||
kind: End | ||
- start_position: | ||
bytes: 10 | ||
line: 1 | ||
character: 11 | ||
end_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
token_type: | ||
type: Symbol | ||
symbol: ) | ||
- start_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
end_position: | ||
bytes: 11 | ||
line: 1 | ||
character: 12 | ||
token_type: | ||
type: Eof |