Skip to content

Instantly share code, notes, and snippets.

@jtenner
Created May 7, 2020 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtenner/223666a4291324f54d7ee537b88162ff to your computer and use it in GitHub Desktop.
Save jtenner/223666a4291324f54d7ee537b88162ff to your computer and use it in GitHub Desktop.
// 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