From 541e80ea592b1225acbe59fea6fd14a20cf9a3f6 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Mon, 8 Aug 2022 00:12:07 +0800 Subject: [PATCH] revert #1353: revert runtime type check to compile time check --- std/assembly/array.ts | 4 ++-- std/assembly/util/error.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 27ff361e30..d82a0da1ff 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -6,7 +6,7 @@ import { COMPARATOR, SORT } from "./util/sort"; import { REVERSE } from "./util/bytes"; import { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string"; import { idof, isArray as builtin_isArray } from "./builtins"; -import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_ILLEGALGENTYPE, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error"; +import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error"; // @ts-ignore: decorator @inline @lazy const MIN_SIZE: usize = 8; @@ -494,7 +494,7 @@ export class Array { flat(): T { if (!isArray()) { - throw new TypeError(E_ILLEGALGENTYPE); + ERROR("Cannot call flat() on Array where T is not an Array."); } // Get the length and data start values var ptr = this.dataStart; diff --git a/std/assembly/util/error.ts b/std/assembly/util/error.ts index f9a0f83d7a..ba3425265b 100644 --- a/std/assembly/util/error.ts +++ b/std/assembly/util/error.ts @@ -13,10 +13,6 @@ export const E_VALUEOUTOFRANGE: string = "Value out of range"; @lazy @inline export const E_INVALIDLENGTH: string = "Invalid length"; -// @ts-ignore: decorator -@lazy @inline -export const E_ILLEGALGENTYPE: string = "Illegal generic type"; - // @ts-ignore: decorator @lazy @inline export const E_EMPTYARRAY: string = "Array is empty";