mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 06:21:29 +00:00
Fix crash when assigning to bool class fields (#95)
With `Type.bool`, size is 1, so dividing by 8 isn't the right way to convert to byteSize. Instead, we need to use the `byteSize` property that does the proper ceiling division.
This commit is contained in:
committed by
Daniel Wirtz
parent
8997561670
commit
ce2bf00d62
16
tests/compiler/class-with-boolean-field.optimized.wat
Normal file
16
tests/compiler/class-with-boolean-field.optimized.wat
Normal file
@ -0,0 +1,16 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class-with-boolean-field/test))
|
||||
(export "memory" (memory $0))
|
||||
(func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32)
|
||||
(local $0 i32)
|
||||
(i32.store8
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.load8_u
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
9
tests/compiler/class-with-boolean-field.ts
Normal file
9
tests/compiler/class-with-boolean-field.ts
Normal file
@ -0,0 +1,9 @@
|
||||
class A {
|
||||
boolValue: bool;
|
||||
}
|
||||
|
||||
export function test(): bool {
|
||||
let a: A;
|
||||
a.boolValue = true;
|
||||
return a.boolValue;
|
||||
}
|
20
tests/compiler/class-with-boolean-field.untouched.wat
Normal file
20
tests/compiler/class-with-boolean-field.untouched.wat
Normal file
@ -0,0 +1,20 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class-with-boolean-field/test))
|
||||
(export "memory" (memory $0))
|
||||
(func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32)
|
||||
(local $0 i32)
|
||||
(nop)
|
||||
(i32.store8
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.load8_u
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
Reference in New Issue
Block a user