Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent parsing multiple literals under StringExpression before 0.5.14 #799

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/four-cats-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

prevent parsing multiple literals under `StringExpression` before `0.5.14`
27 changes: 23 additions & 4 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3688,15 +3688,30 @@ codegen_language_macros::compile!(Language(
Enum(
name = StringExpression,
variants = [
EnumVariant(reference = HexStringLiterals),
EnumVariant(reference = AsciiStringLiterals),
EnumVariant(reference = HexStringLiteral, enabled = Till("0.5.14")),
EnumVariant(
reference = HexStringLiterals,
enabled = From("0.5.14")
),
EnumVariant(
reference = AsciiStringLiteral,
enabled = Till("0.5.14")
),
EnumVariant(
reference = AsciiStringLiterals,
enabled = From("0.5.14")
),
EnumVariant(
reference = UnicodeStringLiterals,
enabled = From("0.7.0")
)
]
),
Repeated(name = HexStringLiterals, reference = HexStringLiteral),
Repeated(
name = HexStringLiterals,
reference = HexStringLiteral,
enabled = From("0.5.14")
),
Token(
name = HexStringLiteral,
definitions = [
Expand Down Expand Up @@ -3740,7 +3755,11 @@ codegen_language_macros::compile!(Language(
Range(inclusive_start = 'A', inclusive_end = 'F')
])
),
Repeated(name = AsciiStringLiterals, reference = AsciiStringLiteral),
Repeated(
name = AsciiStringLiterals,
reference = AsciiStringLiteral,
enabled = From("0.5.14")
),
Token(
name = AsciiStringLiteral,
definitions = [
Expand Down
64 changes: 46 additions & 18 deletions crates/solidity/outputs/cargo/crate/src/generated/language.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions crates/solidity/outputs/spec/generated/grammar.ebnf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ "foo" 'bar' │ 0..11

Errors: # 1 total
- >
Error: Expected end of file.
╭─[crates/solidity/testing/snapshots/cst_output/AsciiStringLiterals/multiple/input.sol:1:1]
1 │ "foo" 'bar'
│ ─────┬─────
│ ╰─────── Error occurred here.
───╯

Tree:
- (SKIPPED): '"foo" ''bar''' # (0..11)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ "foo" │ 0..5

Errors: # 1 total
- >
Error: Expected end of file.
╭─[crates/solidity/testing/snapshots/cst_output/AsciiStringLiterals/single/input.sol:1:1]
1 │ "foo"
│ ──┬──
│ ╰──── Error occurred here.
───╯

Tree:
- (SKIPPED): '"foo"' # (0..5)
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ Source: >

Errors: # 1 total
- >
Error: Expected AsciiStringLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/AsciiStringLiterals/single_trailing_ident/input.sol:1:6]
Error: Expected end of file.
╭─[crates/solidity/testing/snapshots/cst_output/AsciiStringLiterals/single_trailing_ident/input.sol:1:1]
1 │ "foo"bar
──┬
─── Error occurred here.
────┬───
╰────── Error occurred here.
───╯

Tree:
- (AsciiStringLiterals): # '"foo"bar\n' (0..9)
- (item꞉ AsciiStringLiteral): '"foo"' # (0..5)
- (SKIPPED): "bar\n" # (5..9)
- (SKIPPED): '"foo"bar\n' # (0..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ "foo"bar │ 0..8

Errors: # 1 total
- >
Error: Expected AsciiStringLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/AsciiStringLiterals/single_trailing_ident/input.sol:1:6]
1 │ "foo"bar
│ ──┬─
│ ╰─── Error occurred here.
───╯

Tree:
- (AsciiStringLiterals): # '"foo"bar\n' (0..9)
- (item꞉ AsciiStringLiteral): '"foo"' # (0..5)
- (SKIPPED): "bar\n" # (5..9)
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ Tree:
- (LeadingTrivia) ► (Whitespace): " " # (158..159)
- (variant꞉ Identifier): "amount" # (159..165)
- (separator꞉ Comma): "," # (165..166)
- (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ AsciiStringLiterals): # ' "Address: insufficient balance"' (166..198)
- (item꞉ Expression) ► (variant꞉ StringExpression): # ' "Address: insufficient balance"' (166..198)
- (LeadingTrivia) ► (Whitespace): " " # (166..167)
- (item꞉ AsciiStringLiteral): '"Address: insufficient balance"' # (167..198)
- (variant꞉ AsciiStringLiteral): '"Address: insufficient balance"' # (167..198)
- (close_paren꞉ CloseParen): ")" # (198..199)
- (semicolon꞉ Semicolon): ";" # (199..200)
- (TrailingTrivia) ► (EndOfLine): "\n" # (200..201)
Expand Down Expand Up @@ -132,9 +132,9 @@ Tree:
- (arguments꞉ PositionalArguments): # 'success, "Address: unable to send value, recipient...' (274..343)
- (item꞉ Expression) ► (variant꞉ Identifier): "success" # (274..281)
- (separator꞉ Comma): "," # (281..282)
- (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ AsciiStringLiterals): # ' "Address: unable to send value, recipient may hav...' (282..343)
- (item꞉ Expression) ► (variant꞉ StringExpression): # ' "Address: unable to send value, recipient may hav...' (282..343)
- (LeadingTrivia) ► (Whitespace): " " # (282..283)
- (item꞉ AsciiStringLiteral): '"Address: unable to send value, recipient may have...' # (283..343)
- (variant꞉ AsciiStringLiteral): '"Address: unable to send value, recipient may have...' # (283..343)
- (close_paren꞉ CloseParen): ")" # (343..344)
- (semicolon꞉ Semicolon): ";" # (344..345)
- (TrailingTrivia) ► (EndOfLine): "\n" # (345..346)
Expand Down
Loading