Skip to content

Commit

Permalink
fix: Remove optimization for re-interpret cast on integer constants
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel committed Oct 11, 2024
1 parent 6f2d9cd commit 35d9216
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
7 changes: 0 additions & 7 deletions src/awst/node-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,6 @@ const explicitNodeFactory = {
sourceLocation,
})
}
if (expr instanceof IntegerConstant) {
return new IntegerConstant({
...expr,
wtype,
sourceLocation,
})
}

return new ReinterpretCast({
expr,
Expand Down
2 changes: 1 addition & 1 deletion tests/approvals/out/byte-expressions.awst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subroutine test(a: uint64, b: biguint, c: string): void
assert(len(0x) == 0)
assert(itob(a) == itob(a))
assert(0x01 == 0x0000000000000001)
assert(256 == 0x0100)
assert(reinterpret_cast<bytes>(256) == 0x0100)
assert(reinterpret_cast<biguint>(reinterpret_cast<bytes>(b)) == b)
assert(reinterpret_cast<string>(reinterpret_cast<bytes>(c)) == c)
assert("123" == "123")
Expand Down
23 changes: 20 additions & 3 deletions tests/approvals/out/byte-expressions.awst.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
"scalar_type": 2
},
"lhs": {
"_type": "IntegerConstant",
"_type": "ReinterpretCast",
"source_location": {
"file": "tests/approvals/byte-expressions.algo.ts",
"line": 8,
Expand All @@ -469,8 +469,25 @@
"ephemeral": false,
"scalar_type": 1
},
"value": "256",
"teal_alias": null
"expr": {
"_type": "IntegerConstant",
"source_location": {
"file": "tests/approvals/byte-expressions.algo.ts",
"line": 8,
"end_line": 8,
"column": 15,
"end_column": 27
},
"wtype": {
"_type": "WType",
"name": "biguint",
"immutable": true,
"ephemeral": false,
"scalar_type": 1
},
"value": "256",
"teal_alias": null
}
},
"operator": "==",
"rhs": {
Expand Down

0 comments on commit 35d9216

Please sign in to comment.