Skip to content

Commit 04620c2

Browse files
authored
Fix error in type of memory.init introduced in #56 (#57)
Sorry for the churn. This time I'll double check the test in wabt before updating the testsuite repo.
1 parent 394c31b commit 04620c2

File tree

3 files changed

+71
-71
lines changed

3 files changed

+71
-71
lines changed

interpreter/valid/valid.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type
407407
| MemoryInit x ->
408408
let MemoryType (_, it) = memory c (0l @@ e.at) in
409409
ignore (data c x);
410-
[value_type_of_index_type it; value_type_of_index_type it; value_type_of_index_type it] --> []
410+
[value_type_of_index_type it; NumType I32Type; NumType I32Type] --> []
411411

412412
| DataDrop x ->
413413
ignore (data c x);

test/core/memory_init.wast

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@
10171017
(data (i64.const 12) "\07\05\02\03\06")
10181018
(data "\05\09\02\07\06")
10191019
(func (export "test")
1020-
(memory.init 1 (i64.const 7) (i64.const 0) (i64.const 4)))
1020+
(memory.init 1 (i64.const 7) (i32.const 0) (i32.const 4)))
10211021
(func (export "load8_u") (param i64) (result i32)
10221022
(i32.load8_u (local.get 0))))
10231023

@@ -1061,7 +1061,7 @@
10611061
(data (i64.const 12) "\07\05\02\03\06")
10621062
(data "\05\09\02\07\06")
10631063
(func (export "test")
1064-
(memory.init 3 (i64.const 15) (i64.const 1) (i64.const 3)))
1064+
(memory.init 3 (i64.const 15) (i32.const 1) (i32.const 3)))
10651065
(func (export "load8_u") (param i64) (result i32)
10661066
(i32.load8_u (local.get 0))))
10671067

@@ -1105,9 +1105,9 @@
11051105
(data (i64.const 12) "\07\05\02\03\06")
11061106
(data "\05\09\02\07\06")
11071107
(func (export "test")
1108-
(memory.init 1 (i64.const 7) (i64.const 0) (i64.const 4))
1108+
(memory.init 1 (i64.const 7) (i32.const 0) (i32.const 4))
11091109
(data.drop 1)
1110-
(memory.init 3 (i64.const 15) (i64.const 1) (i64.const 3))
1110+
(memory.init 3 (i64.const 15) (i32.const 1) (i32.const 3))
11111111
(data.drop 3)
11121112
(memory.copy (i64.const 20) (i64.const 15) (i64.const 5))
11131113
(memory.copy (i64.const 21) (i64.const 29) (i64.const 1))
@@ -1176,99 +1176,99 @@
11761176
(data "\37")
11771177
(func (export "test")
11781178
(data.drop 0)
1179-
(memory.init 0 (i64.const 1234) (i64.const 1) (i64.const 1))))
1179+
(memory.init 0 (i64.const 1234) (i32.const 1) (i32.const 1))))
11801180
(assert_trap (invoke "test") "out of bounds memory access")
11811181

11821182
(module
11831183
(memory i64 1)
11841184
(data (i64.const 0) "\37")
11851185
(func (export "test")
1186-
(memory.init 0 (i64.const 1234) (i64.const 1) (i64.const 1))))
1186+
(memory.init 0 (i64.const 1234) (i32.const 1) (i32.const 1))))
11871187
(assert_trap (invoke "test") "out of bounds memory access")
11881188

11891189
(assert_invalid
11901190
(module
11911191
(func (export "test")
1192-
(memory.init 1 (i64.const 1234) (i64.const 1) (i64.const 1))))
1192+
(memory.init 1 (i64.const 1234) (i32.const 1) (i32.const 1))))
11931193
"unknown memory 0")
11941194

11951195
(assert_invalid
11961196
(module
11971197
(memory i64 1)
11981198
(data "\37")
11991199
(func (export "test")
1200-
(memory.init 1 (i64.const 1234) (i64.const 1) (i64.const 1))))
1200+
(memory.init 1 (i64.const 1234) (i32.const 1) (i32.const 1))))
12011201
"unknown data segment 1")
12021202

12031203
(module
12041204
(memory i64 1)
12051205
(data "\37")
12061206
(func (export "test")
1207-
(memory.init 0 (i64.const 1) (i64.const 0) (i64.const 1))
1208-
(memory.init 0 (i64.const 1) (i64.const 0) (i64.const 1))))
1207+
(memory.init 0 (i64.const 1) (i32.const 0) (i32.const 1))
1208+
(memory.init 0 (i64.const 1) (i32.const 0) (i32.const 1))))
12091209
(invoke "test")
12101210

12111211
(module
12121212
(memory i64 1)
12131213
(data "\37")
12141214
(func (export "test")
1215-
(memory.init 0 (i64.const 1234) (i64.const 0) (i64.const 5))))
1215+
(memory.init 0 (i64.const 1234) (i32.const 0) (i32.const 5))))
12161216
(assert_trap (invoke "test") "out of bounds memory access")
12171217

12181218
(module
12191219
(memory i64 1)
12201220
(data "\37")
12211221
(func (export "test")
1222-
(memory.init 0 (i64.const 1234) (i64.const 2) (i64.const 3))))
1222+
(memory.init 0 (i64.const 1234) (i32.const 2) (i32.const 3))))
12231223
(assert_trap (invoke "test") "out of bounds memory access")
12241224

12251225
(module
12261226
(memory i64 1)
12271227
(data "\37")
12281228
(func (export "test")
1229-
(memory.init 0 (i64.const 0xFFFE) (i64.const 1) (i64.const 3))))
1229+
(memory.init 0 (i64.const 0xFFFE) (i32.const 1) (i32.const 3))))
12301230
(assert_trap (invoke "test") "out of bounds memory access")
12311231

12321232
(module
12331233
(memory i64 1)
12341234
(data "\37")
12351235
(func (export "test")
1236-
(memory.init 0 (i64.const 1234) (i64.const 4) (i64.const 0))))
1236+
(memory.init 0 (i64.const 1234) (i32.const 4) (i32.const 0))))
12371237
(assert_trap (invoke "test") "out of bounds memory access")
12381238

12391239
(module
12401240
(memory i64 1)
12411241
(data "\37")
12421242
(func (export "test")
1243-
(memory.init 0 (i64.const 1234) (i64.const 1) (i64.const 0))))
1243+
(memory.init 0 (i64.const 1234) (i32.const 1) (i32.const 0))))
12441244
(invoke "test")
12451245

12461246
(module
12471247
(memory i64 1)
12481248
(data "\37")
12491249
(func (export "test")
1250-
(memory.init 0 (i64.const 0x10001) (i64.const 0) (i64.const 0))))
1250+
(memory.init 0 (i64.const 0x10001) (i32.const 0) (i32.const 0))))
12511251
(assert_trap (invoke "test") "out of bounds memory access")
12521252

12531253
(module
12541254
(memory i64 1)
12551255
(data "\37")
12561256
(func (export "test")
1257-
(memory.init 0 (i64.const 0x10000) (i64.const 0) (i64.const 0))))
1257+
(memory.init 0 (i64.const 0x10000) (i32.const 0) (i32.const 0))))
12581258
(invoke "test")
12591259

12601260
(module
12611261
(memory i64 1)
12621262
(data "\37")
12631263
(func (export "test")
1264-
(memory.init 0 (i64.const 0x10000) (i64.const 1) (i64.const 0))))
1264+
(memory.init 0 (i64.const 0x10000) (i32.const 1) (i32.const 0))))
12651265
(invoke "test")
12661266

12671267
(module
12681268
(memory i64 1)
12691269
(data "\37")
12701270
(func (export "test")
1271-
(memory.init 0 (i64.const 0x10001) (i64.const 4) (i64.const 0))))
1271+
(memory.init 0 (i64.const 0x10001) (i32.const 4) (i32.const 0))))
12721272
(assert_trap (invoke "test") "out of bounds memory access")
12731273

12741274
(assert_invalid
@@ -1527,14 +1527,6 @@
15271527
(memory.init 0 (f32.const 1) (f64.const 1) (f64.const 1))))
15281528
"type mismatch")
15291529

1530-
(assert_invalid
1531-
(module
1532-
(memory i64 1)
1533-
(data "\37")
1534-
(func (export "test")
1535-
(memory.init 0 (i64.const 1) (i32.const 1) (i32.const 1))))
1536-
"type mismatch")
1537-
15381530
(assert_invalid
15391531
(module
15401532
(memory i64 1)
@@ -1607,6 +1599,14 @@
16071599
(memory.init 0 (i64.const 1) (i64.const 1) (f32.const 1))))
16081600
"type mismatch")
16091601

1602+
(assert_invalid
1603+
(module
1604+
(memory i64 1)
1605+
(data "\37")
1606+
(func (export "test")
1607+
(memory.init 0 (i64.const 1) (i64.const 1) (i64.const 1))))
1608+
"type mismatch")
1609+
16101610
(assert_invalid
16111611
(module
16121612
(memory i64 1)
@@ -1790,10 +1790,10 @@
17901790
(br $cont))))
17911791
(return (local.get $from)))
17921792

1793-
(func (export "run") (param $offs i64) (param $len i64)
1794-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1793+
(func (export "run") (param $offs i64) (param $len i32)
1794+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
17951795

1796-
(assert_trap (invoke "run" (i64.const 65528) (i64.const 16))
1796+
(assert_trap (invoke "run" (i64.const 65528) (i32.const 16))
17971797
"out of bounds memory access")
17981798

17991799
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1813,10 +1813,10 @@
18131813
(br $cont))))
18141814
(return (local.get $from)))
18151815

1816-
(func (export "run") (param $offs i64) (param $len i64)
1817-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1816+
(func (export "run") (param $offs i64) (param $len i32)
1817+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
18181818

1819-
(assert_trap (invoke "run" (i64.const 65527) (i64.const 16))
1819+
(assert_trap (invoke "run" (i64.const 65527) (i32.const 16))
18201820
"out of bounds memory access")
18211821

18221822
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1836,10 +1836,10 @@
18361836
(br $cont))))
18371837
(return (local.get $from)))
18381838

1839-
(func (export "run") (param $offs i64) (param $len i64)
1840-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1839+
(func (export "run") (param $offs i64) (param $len i32)
1840+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
18411841

1842-
(assert_trap (invoke "run" (i64.const 65472) (i64.const 30))
1842+
(assert_trap (invoke "run" (i64.const 65472) (i32.const 30))
18431843
"out of bounds memory access")
18441844

18451845
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1859,10 +1859,10 @@
18591859
(br $cont))))
18601860
(return (local.get $from)))
18611861

1862-
(func (export "run") (param $offs i64) (param $len i64)
1863-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1862+
(func (export "run") (param $offs i64) (param $len i32)
1863+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
18641864

1865-
(assert_trap (invoke "run" (i64.const 65473) (i64.const 31))
1865+
(assert_trap (invoke "run" (i64.const 65473) (i32.const 31))
18661866
"out of bounds memory access")
18671867

18681868
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1882,10 +1882,10 @@
18821882
(br $cont))))
18831883
(return (local.get $from)))
18841884

1885-
(func (export "run") (param $offs i64) (param $len i64)
1886-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1885+
(func (export "run") (param $offs i64) (param $len i32)
1886+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
18871887

1888-
(assert_trap (invoke "run" (i64.const 65528) (i64.const 4294967040))
1888+
(assert_trap (invoke "run" (i64.const 65528) (i32.const 4294967040))
18891889
"out of bounds memory access")
18901890

18911891
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1905,10 +1905,10 @@
19051905
(br $cont))))
19061906
(return (local.get $from)))
19071907

1908-
(func (export "run") (param $offs i64) (param $len i64)
1909-
(memory.init 0 (local.get $offs) (i64.const 0) (local.get $len))))
1908+
(func (export "run") (param $offs i64) (param $len i32)
1909+
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))
19101910

1911-
(assert_trap (invoke "run" (i64.const 0) (i64.const 4294967292))
1911+
(assert_trap (invoke "run" (i64.const 0) (i32.const 4294967292))
19121912
"out of bounds memory access")
19131913

19141914
(assert_return (invoke "checkRange" (i64.const 0) (i64.const 1) (i32.const 0))
@@ -1927,4 +1927,4 @@
19271927
(data "") (data "") (data "") (data "") (data "") (data "") (data "") (data "")
19281928
(data "") (data "") (data "") (data "") (data "") (data "") (data "") (data "")
19291929
(data "")
1930-
(func (memory.init 64 (i64.const 0) (i64.const 0) (i64.const 0))))
1930+
(func (memory.init 64 (i64.const 0) (i32.const 0) (i32.const 0))))

0 commit comments

Comments
 (0)