diff --git a/.changeset/poor-lemons-hammer.md b/.changeset/poor-lemons-hammer.md new file mode 100644 index 0000000000..1c014f9ec3 --- /dev/null +++ b/.changeset/poor-lemons-hammer.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": patch +--- + +Support arbitrary ASCII escape sequences in string literals until 0.4.25 diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index afc260a449..650cfb522d 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -3820,9 +3820,21 @@ codegen_language_macros::compile!(Language( Token( name = SingleQuotedStringLiteral, definitions = [ - // Allows unicode characters: + // Allows unicode characters and arbitrary escape sequences: TokenDefinition( - enabled = Till("0.7.0"), + enabled = Till("0.4.25"), + scanner = Sequence([ + Atom("'"), + ZeroOrMore(Choice([ + Fragment(EscapeSequenceArbitrary), + Not(['\'', '\\', '\r', '\n']) + ])), + Atom("'") + ]) + ), + // Allows unicode characters but allows only known ASCII escape sequences: + TokenDefinition( + enabled = Range(from = "0.4.25", till = "0.7.0"), scanner = Sequence([ Atom("'"), ZeroOrMore(Choice([ @@ -3850,9 +3862,21 @@ codegen_language_macros::compile!(Language( Token( name = DoubleQuotedStringLiteral, definitions = [ - // Allows unicode characters: + // Allows unicode characters and arbitrary escape sequences: TokenDefinition( - enabled = Till("0.7.0"), + enabled = Till("0.4.25"), + scanner = Sequence([ + Atom("\""), + ZeroOrMore(Choice([ + Fragment(EscapeSequenceArbitrary), + Not(['"', '\\', '\r', '\n']) + ])), + Atom("\"") + ]) + ), + // Allows unicode characters but allows only known ASCII escape sequences: + TokenDefinition( + enabled = Range(from = "0.4.25", till = "0.7.0"), scanner = Sequence([ Atom("\""), ZeroOrMore(Choice([ @@ -3981,6 +4005,20 @@ codegen_language_macros::compile!(Language( ]) ]) ), + Fragment( + name = EscapeSequenceArbitrary, + enabled = Till("0.4.25"), + scanner = Sequence([ + Atom("\\"), + Choice([ + // Prior to 0.4.25, it was legal to "escape" any character (incl. unicode), + // however only the ones from `AsciiEscape` were escaped in practice. + Not(['x', 'u']), + Fragment(HexByteEscape), + Fragment(UnicodeEscape) + ]) + ]) + ), Fragment( name = AsciiEscape, scanner = Choice([ diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs index 911e545699..15a8652b37 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs @@ -36,6 +36,7 @@ pub struct Language { pub(crate) version_is_at_least_0_4_16: bool, pub(crate) version_is_at_least_0_4_21: bool, pub(crate) version_is_at_least_0_4_22: bool, + pub(crate) version_is_at_least_0_4_25: bool, pub(crate) version_is_at_least_0_5_0: bool, pub(crate) version_is_at_least_0_5_3: bool, pub(crate) version_is_at_least_0_5_5: bool, @@ -168,6 +169,7 @@ impl Language { version_is_at_least_0_4_16: Version::new(0, 4, 16) <= version, version_is_at_least_0_4_21: Version::new(0, 4, 21) <= version, version_is_at_least_0_4_22: Version::new(0, 4, 22) <= version, + version_is_at_least_0_4_25: Version::new(0, 4, 25) <= version, version_is_at_least_0_5_0: Version::new(0, 5, 0) <= version, version_is_at_least_0_5_3: Version::new(0, 5, 3) <= version, version_is_at_least_0_5_5: Version::new(0, 5, 5) <= version, @@ -7030,7 +7032,23 @@ impl Language { fn double_quoted_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, - if !self.version_is_at_least_0_7_0 { + if !self.version_is_at_least_0_4_25 { + scan_sequence!( + scan_chars!(input, '"'), + scan_zero_or_more!( + input, + scan_choice!( + input, + self.escape_sequence_arbitrary(input), + scan_none_of!(input, '"', '\\', '\r', '\n') + ) + ), + scan_chars!(input, '"') + ) + } else { + false + }, + if self.version_is_at_least_0_4_25 && !self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, '"'), scan_zero_or_more!( @@ -7108,6 +7126,23 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn escape_sequence_arbitrary(&self, input: &mut ParserContext<'_>) -> bool { + if !self.version_is_at_least_0_4_25 { + scan_sequence!( + scan_chars!(input, '\\'), + scan_choice!( + input, + scan_none_of!(input, 'x', 'u'), + self.hex_byte_escape(input), + self.unicode_escape(input) + ) + ) + } else { + false + } + } + #[allow(unused_assignments, unused_parens)] fn hex_byte_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( @@ -7281,7 +7316,23 @@ impl Language { fn single_quoted_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, - if !self.version_is_at_least_0_7_0 { + if !self.version_is_at_least_0_4_25 { + scan_sequence!( + scan_chars!(input, '\''), + scan_zero_or_more!( + input, + scan_choice!( + input, + self.escape_sequence_arbitrary(input), + scan_none_of!(input, '\'', '\\', '\r', '\n') + ) + ), + scan_chars!(input, '\'') + ) + } else { + false + }, + if self.version_is_at_least_0_4_25 && !self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, '\''), scan_zero_or_more!( diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs index 7596da4a3d..2594d5f48b 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs @@ -54,13 +54,14 @@ mod yul_label; mod yul_leave_statement; mod yul_variable_declaration_statement; -pub const VERSION_BREAKS: [Version; 30] = [ +pub const VERSION_BREAKS: [Version; 31] = [ Version::new(0, 4, 11), Version::new(0, 4, 12), Version::new(0, 4, 14), Version::new(0, 4, 16), Version::new(0, 4, 21), Version::new(0, 4, 22), + Version::new(0, 4, 25), Version::new(0, 5, 0), Version::new(0, 5, 3), Version::new(0, 5, 5), diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/string_literal.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/string_literal.rs index 31f9ee08fc..64f11dfa87 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/string_literal.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/string_literal.rs @@ -9,6 +9,21 @@ fn double_quote_unicode() -> Result<()> { run("StringLiteral", "double_quote_unicode") } +#[test] +fn escape_arbitrary_ascii() -> Result<()> { + run("StringLiteral", "escape_arbitrary_ascii") +} + +#[test] +fn escape_arbitrary_unicode() -> Result<()> { + run("StringLiteral", "escape_arbitrary_unicode") +} + +#[test] +fn escape_ascii() -> Result<()> { + run("StringLiteral", "escape_ascii") +} + #[test] fn escape_cr_double_quote() -> Result<()> { run("StringLiteral", "escape_cr_double_quote") @@ -29,6 +44,16 @@ fn escape_crlf_single_quote() -> Result<()> { run("StringLiteral", "escape_crlf_single_quote") } +#[test] +fn escape_hex() -> Result<()> { + run("StringLiteral", "escape_hex") +} + +#[test] +fn escape_hex_invalid() -> Result<()> { + run("StringLiteral", "escape_hex_invalid") +} + #[test] fn escape_lf_double_quote() -> Result<()> { run("StringLiteral", "escape_lf_double_quote") @@ -39,6 +64,16 @@ fn escape_lf_single_quote() -> Result<()> { run("StringLiteral", "escape_lf_single_quote") } +#[test] +fn escape_unicode() -> Result<()> { + run("StringLiteral", "escape_unicode") +} + +#[test] +fn escape_unicode_invalid() -> Result<()> { + run("StringLiteral", "escape_unicode_invalid") +} + #[test] fn single_quote_unicode() -> Result<()> { run("StringLiteral", "single_quote_unicode") diff --git a/crates/solidity/outputs/spec/generated/grammar.ebnf b/crates/solidity/outputs/spec/generated/grammar.ebnf index cdc23d019f..965ef8cda6 100644 --- a/crates/solidity/outputs/spec/generated/grammar.ebnf +++ b/crates/solidity/outputs/spec/generated/grammar.ebnf @@ -1256,12 +1256,18 @@ StringLiterals = StringLiteral+; StringLiteral = SINGLE_QUOTED_STRING_LITERAL | DOUBLE_QUOTED_STRING_LITERAL; -(* Deprecated in 0.7.0 *) +(* Deprecated in 0.4.25 *) +SINGLE_QUOTED_STRING_LITERAL = "'" («ESCAPE_SEQUENCE_ARBITRARY» | !("'" "\\" "\r" "\n"))* "'"; + +(* Introduced in 0.4.25 and deprecated in 0.7.0. *) SINGLE_QUOTED_STRING_LITERAL = "'" («ESCAPE_SEQUENCE» | !("'" "\\" "\r" "\n"))* "'"; SINGLE_QUOTED_STRING_LITERAL = "'" («ESCAPE_SEQUENCE» | (" "…"&") | ("("…"[") | ("]"…"~"))* "'"; -(* Deprecated in 0.7.0 *) +(* Deprecated in 0.4.25 *) +DOUBLE_QUOTED_STRING_LITERAL = '"' («ESCAPE_SEQUENCE_ARBITRARY» | !('"' "\\" "\r" "\n"))* '"'; + +(* Introduced in 0.4.25 and deprecated in 0.7.0. *) DOUBLE_QUOTED_STRING_LITERAL = '"' («ESCAPE_SEQUENCE» | !('"' "\\" "\r" "\n"))* '"'; DOUBLE_QUOTED_STRING_LITERAL = '"' («ESCAPE_SEQUENCE» | (" "…"!") | ("#"…"[") | ("]"…"~"))* '"'; @@ -1295,6 +1301,9 @@ DOUBLE_QUOTED_UNICODE_STRING_LITERAL = 'unicode"' («ESCAPE_SEQUENCE» | !('"' " «ESCAPE_SEQUENCE» = "\\" («ASCII_ESCAPE» | «HEX_BYTE_ESCAPE» | «UNICODE_ESCAPE»); +(* Deprecated in 0.4.25 *) +«ESCAPE_SEQUENCE_ARBITRARY» = "\\" (!("x" "u") | «HEX_BYTE_ESCAPE» | «UNICODE_ESCAPE»); + «ASCII_ESCAPE» = "n" | "r" | "t" | "'" | '"' | "\\" | "\r\n" | "\r" | "\n"; «HEX_BYTE_ESCAPE» = "x" «HEX_CHARACTER» «HEX_CHARACTER»; diff --git a/crates/solidity/outputs/spec/generated/public/05-expressions/05-strings.md b/crates/solidity/outputs/spec/generated/public/05-expressions/05-strings.md index 601d1ebeb3..031a95d445 100644 --- a/crates/solidity/outputs/spec/generated/public/05-expressions/05-strings.md +++ b/crates/solidity/outputs/spec/generated/public/05-expressions/05-strings.md @@ -26,13 +26,13 @@ ``` -
+ ```{ .ebnf #DoubleQuotedStringLiteral } ``` - + ```{ .ebnf #HexStringLiterals } @@ -100,6 +100,12 @@ +```{ .ebnf #EscapeSequenceArbitrary } + +``` + + + ```{ .ebnf #AsciiEscape } ``` diff --git a/crates/solidity/outputs/spec/generated/public/supported-versions.md b/crates/solidity/outputs/spec/generated/public/supported-versions.md index 4424d2a841..a81ad3a072 100644 --- a/crates/solidity/outputs/spec/generated/public/supported-versions.md +++ b/crates/solidity/outputs/spec/generated/public/supported-versions.md @@ -4,6 +4,6 @@ This specification compiles information from 77 publicly released versions of So `0.4.11` `0.4.12` `0.4.13` `0.4.14` `0.4.15` `0.4.16` `0.4.17` `0.4.18` `0.4.19` `0.4.20` `0.4.21` `0.4.22` `0.4.23` `0.4.24` `0.4.25` `0.4.26` `0.5.0` `0.5.1` `0.5.2` `0.5.3` `0.5.4` `0.5.5` `0.5.6` `0.5.7` `0.5.8` `0.5.9` `0.5.10` `0.5.11` `0.5.12` `0.5.13` `0.5.14` `0.5.15` `0.5.16` `0.5.17` `0.6.0` `0.6.1` `0.6.2` `0.6.3` `0.6.4` `0.6.5` `0.6.6` `0.6.7` `0.6.8` `0.6.9` `0.6.10` `0.6.11` `0.6.12` `0.7.0` `0.7.1` `0.7.2` `0.7.3` `0.7.4` `0.7.5` `0.7.6` `0.8.0` `0.8.1` `0.8.2` `0.8.3` `0.8.4` `0.8.5` `0.8.6` `0.8.7` `0.8.8` `0.8.9` `0.8.10` `0.8.11` `0.8.12` `0.8.13` `0.8.14` `0.8.15` `0.8.16` `0.8.17` `0.8.18` `0.8.19` `0.8.20` `0.8.21` `0.8.22` -Among which, 30 versions have breaking changes: +Among which, 31 versions have breaking changes: -`0.4.11` `0.4.12` `0.4.14` `0.4.16` `0.4.21` `0.4.22` `0.5.0` `0.5.3` `0.5.5` `0.5.8` `0.5.10` `0.5.12` `0.5.14` `0.6.0` `0.6.2` `0.6.5` `0.6.7` `0.6.8` `0.6.11` `0.7.0` `0.7.1` `0.7.4` `0.8.0` `0.8.4` `0.8.7` `0.8.8` `0.8.13` `0.8.18` `0.8.19` `0.8.22` +`0.4.11` `0.4.12` `0.4.14` `0.4.16` `0.4.21` `0.4.22` `0.4.25` `0.5.0` `0.5.3` `0.5.5` `0.5.8` `0.5.10` `0.5.12` `0.5.14` `0.6.0` `0.6.2` `0.6.5` `0.6.7` `0.6.8` `0.6.11` `0.7.0` `0.7.1` `0.7.4` `0.8.0` `0.8.4` `0.8.7` `0.8.8` `0.8.13` `0.8.18` `0.8.19` `0.8.22` diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.11-success.yml new file mode 100644 index 0000000000..352f1d3f31 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.11-success.yml @@ -0,0 +1,14 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Disallowed post 0.4.25 │ 0..25 + 2 │ "\a" │ 26..30 + +Errors: [] + +Tree: + - (StringLiteral): # '// Disallowed post 0.4.25\n"\a"\n' (0..31) + - (leading_trivia꞉ SingleLineComment): "// Disallowed post 0.4.25" # (0..25) + - (leading_trivia꞉ EndOfLine): "\n" # (25..26) + - (variant꞉ DoubleQuotedStringLiteral): '"\a"' # (26..30) + - (trailing_trivia꞉ EndOfLine): "\n" # (30..31) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.25-failure.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.25-failure.yml new file mode 100644 index 0000000000..cf490591b7 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/generated/0.4.25-failure.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Disallowed post 0.4.25 │ 0..25 + 2 │ "\a" │ 26..30 + +Errors: # 1 total + - > + Error: Expected DoubleQuotedStringLiteral or SingleQuotedStringLiteral. + ╭─[crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/input.sol:1:1] + │ + 1 │ ╭─▶ // Disallowed post 0.4.25 + 2 │ ├─▶ "\a" + │ │ + │ ╰────────── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): '// Disallowed post 0.4.25\n"\a"\n' # (0..31) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/input.sol new file mode 100644 index 0000000000..31a30566c4 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_ascii/input.sol @@ -0,0 +1,2 @@ +// Disallowed post 0.4.25 +"\a" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.11-success.yml new file mode 100644 index 0000000000..7d71206e04 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.11-success.yml @@ -0,0 +1,14 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Disallowed post 0.4.25 │ 0..25 + 2 │ "\✅" │ 26..32 + +Errors: [] + +Tree: + - (StringLiteral): # '// Disallowed post 0.4.25\n"\✅"\n' (0..33) + - (leading_trivia꞉ SingleLineComment): "// Disallowed post 0.4.25" # (0..25) + - (leading_trivia꞉ EndOfLine): "\n" # (25..26) + - (variant꞉ DoubleQuotedStringLiteral): '"\✅"' # (26..32) + - (trailing_trivia꞉ EndOfLine): "\n" # (32..33) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.25-failure.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.25-failure.yml new file mode 100644 index 0000000000..0d27f5e4ad --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/generated/0.4.25-failure.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Disallowed post 0.4.25 │ 0..25 + 2 │ "\✅" │ 26..32 + +Errors: # 1 total + - > + Error: Expected DoubleQuotedStringLiteral or SingleQuotedStringLiteral. + ╭─[crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/input.sol:1:1] + │ + 1 │ ╭─▶ // Disallowed post 0.4.25 + 2 │ ├─▶ "\✅" + │ │ + │ ╰─────────── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): '// Disallowed post 0.4.25\n"\✅"\n' # (0..33) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/input.sol new file mode 100644 index 0000000000..16e114a848 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_arbitrary_unicode/input.sol @@ -0,0 +1,2 @@ +// Disallowed post 0.4.25 +"\✅" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/generated/0.4.11-success.yml new file mode 100644 index 0000000000..a714c11932 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/generated/0.4.11-success.yml @@ -0,0 +1,11 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ "\n" │ 0..4 + +Errors: [] + +Tree: + - (StringLiteral): # '"\n"\n' (0..5) + - (variant꞉ DoubleQuotedStringLiteral): '"\n"' # (0..4) + - (trailing_trivia꞉ EndOfLine): "\n" # (4..5) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/input.sol new file mode 100644 index 0000000000..a6edaba19b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_ascii/input.sol @@ -0,0 +1 @@ +"\n" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/generated/0.4.11-success.yml new file mode 100644 index 0000000000..1954ed03f1 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/generated/0.4.11-success.yml @@ -0,0 +1,11 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ "\x0a" │ 0..6 + +Errors: [] + +Tree: + - (StringLiteral): # '"\x0a"\n' (0..7) + - (variant꞉ DoubleQuotedStringLiteral): '"\x0a"' # (0..6) + - (trailing_trivia꞉ EndOfLine): "\n" # (6..7) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/input.sol new file mode 100644 index 0000000000..7e7d55dfb5 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex/input.sol @@ -0,0 +1 @@ +"\x0a" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..bb1094026d --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/generated/0.4.11-failure.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ "\x1" │ 0..5 + +Errors: # 1 total + - > + Error: Expected DoubleQuotedStringLiteral or SingleQuotedStringLiteral. + ╭─[crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/input.sol:1:1] + │ + 1 │ "\x1" + │ ───┬── + │ ╰──── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): '"\x1"\n' # (0..6) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/input.sol new file mode 100644 index 0000000000..dcc5589d27 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_hex_invalid/input.sol @@ -0,0 +1 @@ +"\x1" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/generated/0.4.11-success.yml new file mode 100644 index 0000000000..65ad4e4bd3 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/generated/0.4.11-success.yml @@ -0,0 +1,11 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ "\u263A" │ 0..8 + +Errors: [] + +Tree: + - (StringLiteral): # '"\u263A"\n' (0..9) + - (variant꞉ DoubleQuotedStringLiteral): '"\u263A"' # (0..8) + - (trailing_trivia꞉ EndOfLine): "\n" # (8..9) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/input.sol new file mode 100644 index 0000000000..927cb0f99c --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode/input.sol @@ -0,0 +1 @@ +"\u263A" diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..5ba9d6169e --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/generated/0.4.11-failure.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ "\u123" │ 0..7 + +Errors: # 1 total + - > + Error: Expected DoubleQuotedStringLiteral or SingleQuotedStringLiteral. + ╭─[crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/input.sol:1:1] + │ + 1 │ "\u123" + │ ────┬─── + │ ╰───── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): '"\u123"\n' # (0..8) diff --git a/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/input.sol b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/input.sol new file mode 100644 index 0000000000..8eb3920a4b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/StringLiteral/escape_unicode_invalid/input.sol @@ -0,0 +1 @@ +"\u123"