Skip to content

Commit 541e80e

Browse files
committed
revert AssemblyScript#1353: revert runtime type check to compile time check
1 parent 24a908d commit 541e80e

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

std/assembly/array.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { COMPARATOR, SORT } from "./util/sort";
66
import { REVERSE } from "./util/bytes";
77
import { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string";
88
import { idof, isArray as builtin_isArray } from "./builtins";
9-
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_ILLEGALGENTYPE, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";
9+
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";
1010

1111
// @ts-ignore: decorator
1212
@inline @lazy const MIN_SIZE: usize = 8;
@@ -494,7 +494,7 @@ export class Array<T> {
494494

495495
flat(): T {
496496
if (!isArray<T>()) {
497-
throw new TypeError(E_ILLEGALGENTYPE);
497+
ERROR("Cannot call flat() on Array<T> where T is not an Array.");
498498
}
499499
// Get the length and data start values
500500
var ptr = this.dataStart;

std/assembly/util/error.ts

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export const E_VALUEOUTOFRANGE: string = "Value out of range";
1313
@lazy @inline
1414
export const E_INVALIDLENGTH: string = "Invalid length";
1515

16-
// @ts-ignore: decorator
17-
@lazy @inline
18-
export const E_ILLEGALGENTYPE: string = "Illegal generic type";
19-
2016
// @ts-ignore: decorator
2117
@lazy @inline
2218
export const E_EMPTYARRAY: string = "Array is empty";

0 commit comments

Comments
 (0)