mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 18:26:40 +00:00
possible-null assignment to non-null, notes
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
(export "testLogicalOr" (func $possibly-null/testTrue))
|
||||
(export "testLogicalAndMulti" (func $possibly-null/testLogicalAndMulti))
|
||||
(export "testLogicalOrMulti" (func $possibly-null/testLogicalAndMulti))
|
||||
(export "testAssign" (func $possibly-null/testLogicalAndMulti))
|
||||
(func $possibly-null/testTrue (; 0 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||
nop
|
||||
)
|
||||
|
@ -99,14 +99,23 @@ export function testLogicalAndMulti(a: Ref | null, b: Ref | null): void {
|
||||
if (a && b) {
|
||||
if (isNullable(a)) ERROR("should be non-nullable");
|
||||
if (isNullable(b)) ERROR("should be non-nullable");
|
||||
} else {
|
||||
if (!isNullable(a)) ERROR("should be nullable");
|
||||
if (!isNullable(b)) ERROR("should be nullable");
|
||||
}
|
||||
}
|
||||
|
||||
export function testLogicalOrMulti(a: Ref | null, b: Ref | null): void {
|
||||
if (!a || !b) {
|
||||
// something
|
||||
if (!isNullable(a)) ERROR("should be nullable");
|
||||
if (!isNullable(b)) ERROR("should be nullable");
|
||||
} else {
|
||||
if (isNullable(a)) ERROR("should be non-nullable");
|
||||
if (isNullable(b)) ERROR("should be non-nullable");
|
||||
}
|
||||
}
|
||||
|
||||
export function testAssign(a: Ref | null, b: Ref): void {
|
||||
a = b;
|
||||
if (isNullable(a)) ERROR("should be non-nullable");
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
(export "testLogicalOr" (func $possibly-null/testLogicalOr))
|
||||
(export "testLogicalAndMulti" (func $possibly-null/testLogicalAndMulti))
|
||||
(export "testLogicalOrMulti" (func $possibly-null/testLogicalOrMulti))
|
||||
(export "testAssign" (func $possibly-null/testAssign))
|
||||
(func $possibly-null/testTrue (; 0 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||
local.get $0
|
||||
if
|
||||
@ -168,6 +169,8 @@
|
||||
end
|
||||
if
|
||||
nop
|
||||
else
|
||||
nop
|
||||
end
|
||||
)
|
||||
(func $possibly-null/testLogicalOrMulti (; 16 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
|
||||
@ -185,6 +188,10 @@
|
||||
nop
|
||||
end
|
||||
)
|
||||
(func $null (; 17 ;) (type $FUNCSIG$v)
|
||||
(func $possibly-null/testAssign (; 17 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
|
||||
local.get $1
|
||||
local.set $0
|
||||
)
|
||||
(func $null (; 18 ;) (type $FUNCSIG$v)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user