mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 19:51:47 +00:00
null checking throughout logical and/or
This commit is contained in:
@ -83,16 +83,30 @@ export function testWhile3(a: Ref | null, b: Ref | null): void {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
function requireNonNull(a: Ref): Ref {
|
||||
return a;
|
||||
}
|
||||
|
||||
// function requireNonNull(a: Ref): Ref {
|
||||
// return a;
|
||||
// }
|
||||
export function testLogicalAnd(a: Ref | null): void {
|
||||
a && requireNonNull(a);
|
||||
}
|
||||
|
||||
// export function testLogicalAnd(a: Ref | null): void {
|
||||
// a && requireNonNull(a);
|
||||
// }
|
||||
export function testLogicalOr(a: Ref | null): void {
|
||||
!a || requireNonNull(a) != null;
|
||||
}
|
||||
|
||||
// export function testLogicalOr(a: Ref | null): void {
|
||||
// !a || requireNonNull(a);
|
||||
// }
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
export function testLogicalOrMulti(a: Ref | null, b: Ref | null): void {
|
||||
if (!a || !b) {
|
||||
// something
|
||||
} else {
|
||||
if (isNullable(a)) ERROR("should be non-nullable");
|
||||
if (isNullable(b)) ERROR("should be non-nullable");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user