Commit 2616eb2
[ddc] Use TemporaryId when emitting all kernel VariableDeclaration references.
Some CFE lowerings (e.g. pattern lowerings) result in nested scopes containing VariableDeclarations with the same 'name'. The current DDC transform translates these to the exact same name in JS leading to incorrect semantics.
The `TemporaryId` mechanism automatically renames any variables with the same name that would shadow each other. So we re-use that here to ensure the variables all have a unique name if the CFE hasn't already given them one. If the name is already okay (i.e. not shadowing something else), the name in JS will appear unchanged.
Side note: In a future change perhaps we should rename `TemporaryId`. The general mechanism it implements is more useful than its original intended use.
Fixes: #59613
Change-Id: I708c72528d5df19af48dde01163d375a5588baae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398504
Commit-Queue: Nate Biggs <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
Reviewed-by: Nicholas Shahan <[email protected]>1 parent cd7b134 commit 2616eb2
File tree
8 files changed
+342
-40
lines changed- pkg/dev_compiler
- lib/src
- compiler
- kernel
- test/expression_compiler
- sdk/lib/_internal/js_dev_runtime
- patch
- private/ddc_runtime
- tests/language/patterns
8 files changed
+342
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 32 | + | |
| 33 | + | |
46 | 34 | | |
47 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
48 | 45 | | |
49 | | - | |
| 46 | + | |
50 | 47 | | |
51 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
| |||
4930 | 4939 | | |
4931 | 4940 | | |
4932 | 4941 | | |
4933 | | - | |
| 4942 | + | |
| 4943 | + | |
4934 | 4944 | | |
4935 | 4945 | | |
4936 | 4946 | | |
| |||
4964 | 4974 | | |
4965 | 4975 | | |
4966 | 4976 | | |
4967 | | - | |
| 4977 | + | |
4968 | 4978 | | |
4969 | 4979 | | |
4970 | 4980 | | |
| |||
4978 | 4988 | | |
4979 | 4989 | | |
4980 | 4990 | | |
4981 | | - | |
| 4991 | + | |
| 4992 | + | |
4982 | 4993 | | |
4983 | 4994 | | |
4984 | 4995 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
251 | 260 | | |
252 | 261 | | |
253 | 262 | | |
| |||
5250 | 5259 | | |
5251 | 5260 | | |
5252 | 5261 | | |
5253 | | - | |
| 5262 | + | |
| 5263 | + | |
5254 | 5264 | | |
5255 | 5265 | | |
5256 | 5266 | | |
| |||
5284 | 5294 | | |
5285 | 5295 | | |
5286 | 5296 | | |
5287 | | - | |
| 5297 | + | |
5288 | 5298 | | |
5289 | 5299 | | |
5290 | 5300 | | |
| |||
5298 | 5308 | | |
5299 | 5309 | | |
5300 | 5310 | | |
5301 | | - | |
| 5311 | + | |
| 5312 | + | |
5302 | 5313 | | |
5303 | 5314 | | |
5304 | 5315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
118 | 188 | | |
119 | 189 | | |
120 | | - | |
121 | | - | |
| 190 | + | |
| 191 | + | |
122 | 192 | | |
123 | 193 | | |
124 | 194 | | |
| |||
128 | 198 | | |
129 | 199 | | |
130 | 200 | | |
131 | | - | |
| 201 | + | |
132 | 202 | | |
133 | 203 | | |
134 | 204 | | |
| |||
177 | 247 | | |
178 | 248 | | |
179 | 249 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 250 | | |
187 | 251 | | |
188 | 252 | | |
| |||
0 commit comments