Skip to content

Commit 28fdf3b

Browse files
fix misleading compile error on multi-assignment
multiassignment causes compiler error later on code that has no errors fix #1699
1 parent d4e7b9d commit 28fdf3b

File tree

101 files changed

+32023
-23540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+32023
-23540
lines changed

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ under the licensing terms detailed in LICENSE:
3333
* Piotr Oleś <piotrek.oles@gmail.com>
3434
* Saúl Cabrera <saulecabrera@gmail.com>
3535
* Chance Snow <git@chancesnow.me>
36+
* Peter Salomonsen <petersalomonsen@runbox.com>
3637

3738
Portions of this software are derived from third-party works licensed under
3839
the following terms:

src/flow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ export class Flow {
327327
}
328328
local = parentFunction.addLocal(type);
329329
} else {
330-
if (temps !== null && temps.length > 0) {
330+
if (temps !== null && temps.length > 0
331+
&& temps[temps.length-1].type === type) {
331332
local = assert(temps.pop());
332333
local.type = type;
333334
local.flags = CommonFlags.NONE;

tests/compiler/abi.untouched.wat

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
end
132132
i32.const 2
133133
i32.ctz
134-
local.set $0
135-
local.get $0
134+
local.set $1
135+
local.get $1
136136
i32.const 0
137137
i32.ne
138138
i32.eqz
@@ -146,8 +146,8 @@
146146
end
147147
i32.const 1
148148
i32.clz
149-
local.set $0
150-
local.get $0
149+
local.set $1
150+
local.get $1
151151
i32.const 0
152152
i32.ne
153153
i32.eqz
@@ -161,8 +161,8 @@
161161
end
162162
i32.const 2
163163
i32.ctz
164-
local.set $1
165-
local.get $1
164+
local.set $0
165+
local.get $0
166166
i32.eqz
167167
if
168168
i32.const 0
@@ -174,8 +174,8 @@
174174
end
175175
i32.const 1
176176
i32.clz
177-
local.set $1
178-
local.get $1
177+
local.set $0
178+
local.get $0
179179
i32.eqz
180180
if
181181
i32.const 0

tests/compiler/assert-nonnull.untouched.wat

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
(func $assert-nonnull/testAll (param $0 i32) (result i32)
129129
(local $1 i32)
130130
(local $2 i32)
131+
(local $3 i32)
131132
global.get $~lib/memory/__stack_pointer
132133
i32.const 8
133134
i32.sub
@@ -150,18 +151,18 @@
150151
call $~lib/builtins/abort
151152
unreachable
152153
end
153-
local.set $2
154+
local.set $3
154155
global.get $~lib/memory/__stack_pointer
155-
local.get $2
156+
local.get $3
156157
i32.store
157-
local.get $2
158+
local.get $3
158159
i32.const 0
159160
call $~lib/array/Array<assert-nonnull/Foo|null>#__get
160-
local.tee $1
161+
local.tee $2
161162
i32.store offset=4
162-
local.get $1
163+
local.get $2
163164
if (result i32)
164-
local.get $1
165+
local.get $2
165166
else
166167
i32.const 32
167168
i32.const 96
@@ -171,11 +172,11 @@
171172
unreachable
172173
end
173174
i32.load
174-
local.tee $1
175+
local.tee $2
175176
i32.store offset=4
176-
local.get $1
177+
local.get $2
177178
if (result i32)
178-
local.get $1
179+
local.get $2
179180
else
180181
i32.const 32
181182
i32.const 96
@@ -184,16 +185,17 @@
184185
call $~lib/builtins/abort
185186
unreachable
186187
end
187-
local.set $2
188+
local.set $3
188189
global.get $~lib/memory/__stack_pointer
189190
i32.const 8
190191
i32.add
191192
global.set $~lib/memory/__stack_pointer
192-
local.get $2
193+
local.get $3
193194
)
194195
(func $assert-nonnull/testAll2 (param $0 i32) (result i32)
195196
(local $1 i32)
196197
(local $2 i32)
198+
(local $3 i32)
197199
global.get $~lib/memory/__stack_pointer
198200
i32.const 8
199201
i32.sub
@@ -216,18 +218,18 @@
216218
call $~lib/builtins/abort
217219
unreachable
218220
end
219-
local.set $2
221+
local.set $3
220222
global.get $~lib/memory/__stack_pointer
221-
local.get $2
223+
local.get $3
222224
i32.store
223-
local.get $2
225+
local.get $3
224226
i32.const 0
225227
call $~lib/array/Array<assert-nonnull/Foo|null>#__get
226-
local.tee $1
228+
local.tee $2
227229
i32.store offset=4
228-
local.get $1
230+
local.get $2
229231
if (result i32)
230-
local.get $1
232+
local.get $2
231233
else
232234
i32.const 32
233235
i32.const 96
@@ -237,11 +239,11 @@
237239
unreachable
238240
end
239241
i32.load
240-
local.tee $1
242+
local.tee $2
241243
i32.store offset=4
242-
local.get $1
244+
local.get $2
243245
if (result i32)
244-
local.get $1
246+
local.get $2
245247
else
246248
i32.const 32
247249
i32.const 96
@@ -250,12 +252,12 @@
250252
call $~lib/builtins/abort
251253
unreachable
252254
end
253-
local.set $2
255+
local.set $3
254256
global.get $~lib/memory/__stack_pointer
255257
i32.const 8
256258
i32.add
257259
global.set $~lib/memory/__stack_pointer
258-
local.get $2
260+
local.get $3
259261
)
260262
(func $assert-nonnull/testProp (param $0 i32) (result i32)
261263
(local $1 i32)

0 commit comments

Comments
 (0)