Skip to content

Commit 37994ff

Browse files
committed
Clear flags on interpolated strings
When inner strings aren't frozen, we need to clear the flags on interpolated string nodes so that we don't emit wrong instructions. The compiler is currently incorrectly emitting frozen strings because the parser is erroneously declaring interpolated strings as "frozen". We need to fix this behavior in the parser so we can fix the compiler in CRuby. This patch is a partial fix for [this bug](https://bugs.ruby-lang.org/issues/21187)
1 parent e5884cd commit 37994ff

31 files changed

Lines changed: 68 additions & 54 deletions

snapshots/dos_endings.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
│ │ ├── flags: ∅
1818
│ │ └── arguments: (length: 1)
1919
│ │ └── @ InterpolatedStringNode (location: (1,5)-(2,12))
20-
│ │ ├── flags: static_literal
20+
│ │ ├── flags:
2121
│ │ ├── opening_loc: ∅
2222
│ │ ├── parts: (length: 2)
2323
│ │ │ ├── @ StringNode (location: (1,5)-(1,9))
@@ -86,7 +86,7 @@
8686
│ │ ├── flags: ∅
8787
│ │ ├── receiver:
8888
│ │ │ @ InterpolatedStringNode (location: (17,8)-(17,14))
89-
│ │ │ ├── flags: static_literal
89+
│ │ │ ├── flags:
9090
│ │ │ ├── opening_loc: (17,8)-(17,14) = "<<~EOF"
9191
│ │ │ ├── parts: (length: 2)
9292
│ │ │ │ ├── @ StringNode (location: (18,0)-(19,0))

snapshots/dstring.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
│ │ └── closing_loc: (5,7)-(5,8) = "}"
4242
│ └── closing_loc: (5,8)-(5,9) = "\""
4343
├── @ InterpolatedStringNode (location: (7,0)-(9,2))
44-
│ ├── flags: newline, static_literal
44+
│ ├── flags: newline
4545
│ ├── opening_loc: ∅
4646
│ ├── parts: (length: 2)
4747
│ │ ├── @ StringNode (location: (7,0)-(8,2))

snapshots/heredocs_leading_whitespace.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
│ ├── closing_loc: (19,0)-(20,0) = " FOO\n"
3131
│ └── unescaped: "a\nb\n"
3232
├── @ InterpolatedStringNode (location: (21,0)-(21,10))
33-
│ ├── flags: newline, static_literal
33+
│ ├── flags: newline
3434
│ ├── opening_loc: (21,0)-(21,10) = "<<~' FOO'"
3535
│ ├── parts: (length: 2)
3636
│ │ ├── @ StringNode (location: (22,0)-(23,0))
@@ -47,7 +47,7 @@
4747
│ │ └── unescaped: "b\n"
4848
│ └── closing_loc: (24,0)-(25,0) = " FOO\n"
4949
└── @ InterpolatedStringNode (location: (26,0)-(26,10))
50-
├── flags: newline, static_literal
50+
├── flags: newline
5151
├── opening_loc: (26,0)-(26,10) = "<<~' FOO'"
5252
├── parts: (length: 2)
5353
│ ├── @ StringNode (location: (27,0)-(28,0))

snapshots/heredocs_nested.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
├── flags: ∅
77
└── body: (length: 2)
88
├── @ InterpolatedStringNode (location: (1,0)-(1,7))
9-
│ ├── flags: newline, static_literal, mutable
9+
│ ├── flags: newline
1010
│ ├── opening_loc: (1,0)-(1,7) = "<<~RUBY"
1111
│ ├── parts: (length: 4)
1212
│ │ ├── @ StringNode (location: (2,0)-(3,0))

snapshots/heredocs_with_fake_newlines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
│ ├── closing_loc: (13,0)-(14,0) = "RUBY\n"
1313
│ └── unescaped: " \n\n \n\n exit\n \\n\n \n\n\n\n\n argh\n \\\n \\ foo\nbar\n \f\n ok\n"
1414
├── @ InterpolatedStringNode (location: (15,0)-(15,7))
15-
│ ├── flags: newline, static_literal
15+
│ ├── flags: newline
1616
│ ├── opening_loc: (15,0)-(15,7) = "<<~RUBY"
1717
│ ├── parts: (length: 11)
1818
│ │ ├── @ StringNode (location: (16,0)-(17,0))

snapshots/heredocs_with_ignored_newlines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
│ ├── closing_loc: (2,0)-(3,0) = "HERE\n"
1313
│ └── unescaped: ""
1414
└── @ InterpolatedStringNode (location: (4,0)-(4,8))
15-
├── flags: newline, static_literal
15+
├── flags: newline
1616
├── opening_loc: (4,0)-(4,8) = "<<~THERE"
1717
├── parts: (length: 9)
1818
│ ├── @ StringNode (location: (5,0)-(6,0))

snapshots/seattlerb/difficult0_.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
│ │ │ ├── flags: ∅
3838
│ │ │ └── arguments: (length: 1)
3939
│ │ │ └── @ InterpolatedStringNode (location: (1,9)-(4,4))
40-
│ │ │ ├── flags: static_literal
40+
│ │ │ ├── flags:
4141
│ │ │ ├── opening_loc: (1,9)-(1,10) = "'"
4242
│ │ │ ├── parts: (length: 2)
4343
│ │ │ │ ├── @ StringNode (location: (1,10)-(2,0))

snapshots/seattlerb/dstr_str.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
├── flags: ∅
77
└── body: (length: 1)
88
└── @ InterpolatedStringNode (location: (1,0)-(1,10))
9-
├── flags: newline, static_literal, mutable
9+
├── flags: newline
1010
├── opening_loc: (1,0)-(1,1) = "\""
1111
├── parts: (length: 2)
1212
│ ├── @ EmbeddedStatementsNode (location: (1,1)-(1,7))

snapshots/seattlerb/heredoc_nested.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
├── flags: ∅
77
└── body: (length: 1)
88
└── @ ArrayNode (location: (1,0)-(7,2))
9-
├── flags: newline, static_literal
9+
├── flags: newline
1010
├── elements: (length: 2)
1111
│ ├── @ InterpolatedStringNode (location: (1,1)-(1,4))
12-
│ │ ├── flags: static_literal, mutable
12+
│ │ ├── flags:
1313
│ │ ├── opening_loc: (1,1)-(1,4) = "<<A"
1414
│ │ ├── parts: (length: 3)
1515
│ │ │ ├── @ EmbeddedStatementsNode (location: (2,0)-(2,6))

snapshots/seattlerb/heredoc_squiggly.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
├── name_loc: (1,0)-(1,1) = "a"
1313
├── value:
1414
│ @ InterpolatedStringNode (location: (1,4)-(1,12))
15-
│ ├── flags: static_literal
15+
│ ├── flags:
1616
│ ├── opening_loc: (1,4)-(1,12) = "<<~\"EOF\""
1717
│ ├── parts: (length: 3)
1818
│ │ ├── @ StringNode (location: (2,0)-(3,0))

0 commit comments

Comments
 (0)