Skip to content

Commit 9975301

Browse files
authored
revert #1353: revert runtime type check to compile time check for Array#flat (#2416)
1 parent 84a06c8 commit 9975301

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

Diff for: NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ under the licensing terms detailed in LICENSE:
4242
* Roman F. <[email protected]>
4343
* Joe Pea <[email protected]>
4444
* Felipe Gasper <[email protected]>
45-
* Congcong Cai <[email protected].com>
45+
* Congcong Cai <congcongcai0907@163.com>
4646
* mooooooi <[email protected]>
4747
* Yasushi Ando <[email protected]>
4848
* Syed Jafri <[email protected]>

Diff for: 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, FILL } 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;
@@ -450,7 +450,7 @@ export class Array<T> {
450450

451451
flat(): T {
452452
if (!isArray<T>()) {
453-
throw new TypeError(E_ILLEGALGENTYPE);
453+
ERROR("Cannot call flat() on Array<T> where T is not an Array.");
454454
}
455455
// Get the length and data start values
456456
var ptr = this.dataStart;

Diff for: 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)