Created
May 7, 2020 21:17
-
-
Save jtenner/223666a4291324f54d7ee537b88162ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The entry file of your WebAssembly module. | |
class OnlyHasUnchecked { | |
length: i32 = 3; | |
@operator("{}") | |
protected __get(index: i32): i32 { | |
return index; | |
} | |
} | |
class OnlyHasChecked { | |
length: i32 = 3; | |
@operator("[]") | |
protected __get(index: i32): i32 { | |
assert(index >= 0); | |
assert(index <= 3); | |
return index; | |
} | |
} | |
let a = new OnlyHasChecked(); | |
let b = new OnlyHasUnchecked(); | |
export function test(): void { | |
if (isDefined(unchecked(a[0]))) { | |
trace("this should not be seeable"); | |
} else { | |
trace("Okay"); | |
} | |
if (isDefined(unchecked(b[0]))) { | |
trace("Okay"); | |
} else { | |
trace("this should not be seeable"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment