Skip to content

Commit

Permalink
Fix error in parser
Browse files Browse the repository at this point in the history
Fix bug when processing sections and trying to read ahead for locals in source code.

Signed-off-by: Ádám László Kulcsár <[email protected]>
  • Loading branch information
kulcsaradam authored and ksh8281 committed Feb 22, 2025
1 parent b64a1ce commit 391d640
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/WASMParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate {

size_t computeExprResultPosition(Walrus::Value::Type type)
{
if (!m_preprocessData.m_inPreprocess) {
if (!m_preprocessData.m_inPreprocess && !m_localInfo.empty()) {
// if there is local.set code ahead,
// we can use local variable position as expr target position
auto localSetInfo = readAheadLocalGetIfExists();
Expand Down
43 changes: 43 additions & 0 deletions test/basic/read_ahead_fix.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(module
(func $some_func)
(table 514 514 funcref)
(elem (i32.const 1) func
$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 $22 $23 $24 $25 $26 $27 $28 $29 $30 $31 $32 $33
)

(func $0)
(func $1)
(func $2)
(func $3)
(func $4)
(func $5)
(func $6)
(func $7)
(func $8)
(func $9)
(func $10)
(func $11)
(func $12)
(func $13)
(func $14)
(func $15)
(func $16)
(func $17)
(func $18)
(func $19)
(func $20)
(func $21)
(func $22)
(func $23)
(func $24)
(func $25)
(func $26)
(func $27)
(func $28)
(func $29)
(func $30)
(func $31)
(func $32)
(func $33)
)

0 comments on commit 391d640

Please sign in to comment.