Teyru

Teyru 診斷碼一覽

每個診斷的穩定代碼格式 TY-<階段>-<四位數字>,以及各階段的代表訊息。

每個診斷都有穩定代碼,格式為 TY-<階段>-<四位數字>。階段前綴:

前綴階段代表
TY-SYN詞法與語法分析分號、括號、換行、字面值
TY-TYP語意分析(名稱、型別、成員)找不到符號、型別不符、多載
TY-PROP原生 property 規則accessor 衝突、儲存需求
TY-INT編譯器內部/前導程式庫前導程式庫損壞、未支援的節點
TY-IO檔案存取讀不到來源檔

輸出格式為 檔案:行:欄: error[碼]: 訊息,例如:

hello.teyru:4:11: error[TY-TYP-0051]: incompatible types: String cannot be converted to int

TY-SYN-0002、0004–0011 由詞法分析器產生(TY-SYN-0001 已移除,見下表;TY-SYN-0003 例外:它是剖析器 在敘述結尾與 throw 換行時發出的),TY-SYN-0100 之後也由剖析器產生。


TY-SYN:詞法與語法

代碼訊息說明與修法
TY-SYN-0001(已移除)分號曾經是錯誤;W7 之後分號被忽略(見〈語言參考〉§1),這個碼不再由編譯器產生。
TY-SYN-0002unexpected character %q出現不屬於任何 token 的字元(多半是全形標點或貼上的控制字元)。
TY-SYN-0003expected end of line, found %s/throw expression must start on the same line敘述後面還有殘餘 token;或 throw 的運算式被換行切斷。把運算式寫在同一行,或用 ( 開頭讓它跨行。需要值的 yield 沒有這個訊息:換行後它被當成識別字,會得到 cannot find symbol yield。
TY-SYN-0004unterminated block comment/* 沒有對應的 */。
TY-SYN-0005invalid unicode escape\uXXXX 不是四位十六進位。
TY-SYN-0006unterminated string literal/unterminated text block字串在換行前沒有收尾,或 text block 少了結尾的 """。
TY-SYN-0007text block must start with a line break after """""" 之後必須立刻換行。
TY-SYN-0008unterminated character literal/character literal does not fit in a char字元常值沒有收尾,或超過 U+FFFF。
TY-SYN-0009malformed integer literal/malformed floating-point literal數字格式錯誤(例如 0x 後面沒有數字、1e 沒有指數)。
TY-SYN-0010integer literal out of range整數字面值超出可表示的位元數:十進位 int 上限 2^31-1、long 上限 2^63-1,非十進位 int 上限 0xFFFFFFFF、long 上限 0xFFFFFFFFFFFFFFFF(界線值會繞成負數)。需要更大的值請加 L 後綴。
TY-SYN-0011invalid escape sequence \%c字串或字元常值裡有 Teyru 不認識的跳脫序列(例如 \q)。合法的有 \n \t \r \b \f \s \0 \\ \' \"、八進位 \nnn 與 \uXXXX。
TY-SYN-0100expected '%s', found %s少了預期的 token()、]、{、}、: 等)。
TY-SYN-0101expected identifier, found %s需要識別字的位置放了別的東西;常見於把關鍵字當名稱使用。
TY-SYN-0102unexpected %s at top level檔案最上層只允許 package/import/型別宣告,或直接寫成員(隱式類別形式)。
TY-SYN-0103unexpected %s in class body類別成員宣告不完整。
TY-SYN-0104expected ',' ':' or '}' after enum constantsenum 常數區與成員區之間要用一個 : 分隔。
TY-SYN-0105expected 'get' or 'set' accessor, found %saccessor 區塊裡只能有 get 與 set。
TY-SYN-0106unexpected %s區塊內出現無法剖析的敘述。
TY-SYN-0107try resources must be separated by line breakstry-with-resources 的每個資源用換行分隔,不能用分號。
TY-SYN-0108try requires catch or finallytry 至少要有一個 catch 或 finally。
TY-SYN-0109expected 'case' or 'default', found %sswitch 區塊裡只能有 case/default。
TY-SYN-0110cannot mix '->' and ':' case labels同一個 switch 只能用一種標籤形式。
TY-SYN-0111expected expression, found %s需要運算式的位置放了別的 token。
TY-SYN-0112array dimension expression after empty dimensionnew int[3][] 之後不能再寫 [5]。
TY-SYN-0113array creation with both dimensions and initializernew int[3]{1,2,3} 不合法;要嘛給大小,要嘛給初始值。

TY-TYP:型別與符號

宣告與成員(0001–0025)

代碼訊息說明與修法
TY-TYP-0001duplicate type %s (also declared at %s)/duplicate nested type %s同名型別重複宣告。
TY-TYP-0002type variable %s cannot have type arguments型別變數不能再帶型別引數。
TY-TYP-0003cannot find type %s型別名稱找不到;檢查拼字、import 或前導程式庫。
TY-TYP-0004type %s expects %d type arguments, found %d泛型引數數量不符。
TY-TYP-0005primitive type %s cannot be a type argument; use its box type泛型不能用原生型別,請用包裝類別。
TY-TYP-0006class cannot extend interface %s類別要用 implements 介面。
TY-TYP-0007cannot extend final class %s被 final 的類別不能被繼承。final 由 @Value/@UtilityClass 標上去時,這一條在標註展開之後才報(「擋下繼承」的檢查原本跑在展開之前,所以那兩個標註沒有作用)。
TY-TYP-0008cyclic inheritance involving %s繼承關係成環。
TY-TYP-0009%s is not an interfaceimplements 後面只能是介面。
TY-TYP-0010duplicate field %s in %s同一個類別重複宣告欄位。
TY-TYP-0011duplicate method %s in %s/duplicate constructor %s參數抹除後簽章相同的方法或建構子重複。
TY-TYP-0012varargs parameter must be last... 只能放在最後一個參數。
TY-TYP-0013interface method with a body must be default, static or private介面方法有 body 時要標 default/static/private。
TY-TYP-0014method %s needs a body非抽象方法要有 body。
TY-TYP-0015abstract or native method %s cannot have a bodyabstract/native 方法不能有 body。
TY-TYP-0016abstract method %s in non-abstract class %s有抽象方法的類別必須標 abstract。
TY-TYP-0017(已移除)native 方法現在可以宣告在任一類別,並以 --native 提供的 C 實作。
TY-TYP-0018'%s' is only allowed for local variables; fields need an explicit typevar/val 不能用在欄位、參數或回傳型別。
TY-TYP-0019%s must implement %s from %s具體類別沒有實作介面或父類別的抽象方法。
TY-TYP-0020missing return statement有回傳值的方法在某些路徑沒有 return。
TY-TYP-0021duplicate local variable %s同一個作用域重複宣告區域變數。
TY-TYP-0022break outside of loop or switchbreak 只能出現在迴圈或 switch 內(有標籤者除外)。
TY-TYP-0023continue outside of loopcontinue 只能出現在迴圈內。
TY-TYP-0024thrown value must be a Throwable, found %sthrow 的物件必須繼承 Throwable。
TY-TYP-0025cannot synchronize on voidsynchronized 的鎖不能是 void 運算式。

陳述式(0026–0044)

代碼訊息說明與修法
TY-TYP-0026local variables cannot be declared final; use 'val'區域變數的不可重綁請用 val。
TY-TYP-0027'%s' requires an initializervar/val 一定要有初始值。
TY-TYP-0028'%s' cannot infer a type from nullnull 無法推斷型別,請寫出明確型別。
TY-TYP-0029'%s' cannot infer a functional interface type; declare it explicitlylambda 需要目標型別,請明確宣告介面型別。
TY-TYP-0030for-each requires an array or Iterable, found %s增強 for 只能用在陣列或 Iterable。
TY-TYP-0031incompatible types: %s is not assignable to %s迴圈變數型別與元素型別不符。
TY-TYP-0032return value required for %s有回傳值的方法不能空手 return。
TY-TYP-0033cannot return a value from a void methodvoid 方法不能回傳值。
TY-TYP-0034catch type must be a Throwable, found %scatch 的型別必須是 Throwable 家族。
TY-TYP-0035switch selector must be a char, byte, short, int, Character, Byte, Short, Integer, String or enum type, found %sswitch 的選擇子型別不合法。
TY-TYP-0036duplicate default label同一個 switch 只能有一個 default。
TY-TYP-0037incompatible pattern type %s for switch on %scase 型別 名 與選擇子型別無關。
TY-TYP-0038case label must be a constant expressioncase 標籤必須是編譯期常數。
TY-TYP-0039duplicate case label同一個 switch 內標籤重複。
TY-TYP-0040array required, found %s對非陣列使用 []。
TY-TYP-0041inconvertible types: %s cannot be cast to %s這個 cast 永遠不可能成立。
TY-TYP-0042incompatible pattern type %s for %sinstanceof pattern 的型別與左邊無關。
TY-TYP-0043not an enclosing class: %sOuter.this 的外層類別不存在。
TY-TYP-0044no superclass沒有父類別卻使用 super。

名稱與存取(0045–0048)

代碼訊息說明與修法
TY-TYP-0045cannot access instance field %s from a static context靜態方法內不能直接讀實例欄位。
TY-TYP-0046%s has private access in %s私有成員只能在自己的類別內存取。property 看的是 accessor 的修飾符(底層儲存一律 private,所以儲存欄位的修飾符不能拿來判斷);x.p = v 看 setter,p.x 與 p.x += 1 看 getter。同一個 nest(同一個最外層類別)內互通。
TY-TYP-0048cannot find symbol %s名稱找不到:檢查拼字、作用域、import,或是否忘了宣告。

型別轉換與運算子(0049–0067)

代碼訊息說明與修法
TY-TYP-0049null is not assignable to %snull 不能給原生型別。
TY-TYP-0050possible lossy conversion from %s to %s需要窄化轉換,請加 cast。
TY-TYP-0051incompatible types: %s cannot be converted to %s最常見的型別錯誤:指派、傳參、回傳的型別不相容。
TY-TYP-0052operator '!' cannot be applied to %s! 只能用在 boolean。
TY-TYP-0053operator '~' requires an integral operand~ 只能用在整數。
TY-TYP-0054operator '%s' requires a numeric operand一元 +/- 只能用在數值。
TY-TYP-0055operator '%s' requires a numeric operand++/-- 只能用在數值。
TY-TYP-0056cannot apply '%s' to a non-assignable expression++/-- 的目標必須可以被指派。
TY-TYP-0057cannot assign a value to final variable %sval 或 final 變數不能再次指派。
TY-TYP-0058cannot assign a value to final field %s不能指派其他類別的 final 欄位。
TY-TYP-0059incompatible operand types %s and %s==/!= 兩邊型別無法比較。
TY-TYP-0060incomparable types: %s and %s兩個參考型別之間不可能相等。
TY-TYP-0061operator '%s' cannot be applied to %s and %s大小比較只能用在數值。
TY-TYP-0062operator '%s' requires integral or boolean operands&/|/^ 的運算元型別不合法。
TY-TYP-0063operator '%s' requires integral operands位移運算子只能用在整數。
TY-TYP-0064operator '%s' cannot be applied to %s and %s算術運算子的運算元不是數值(常見:物件忘了 unbox)。
TY-TYP-0065left-hand side of an assignment must be a variable指派的左邊不能是任意運算式。
TY-TYP-0066operator '%s' cannot be applied to booleanboolean 不能做加減乘除。
TY-TYP-0067(已移除)負的陣列維度曾經是編譯錯誤;javac 編得過 new int[-1],所以 W7 之後它是執行期的 NegativeArraySizeException(見〈語言參考〉§12),這個碼不再由編譯器產生。舊訊息是 array dimension must be non-negative。

建構與實例化(0068–0075)

代碼訊息說明與修法
TY-TYP-0068cannot instantiate %s這個型別不能用 new。
TY-TYP-0069%s is abstract; cannot be instantiated抽象類別不能直接 new。
TY-TYP-0070cannot extend final class %s/cannot subclass enum %s匿名類別不能繼承 final 類別或 enum。
TY-TYP-0071an enclosing instance of %s is required內部類別需要在有外層實例的地方建立。
TY-TYP-0072no suitable constructor found for %s(%s)沒有相符的建構子;檢查參數數量與型別。
TY-TYP-0073array clone takes no argumentsclone() 不接受參數。
TY-TYP-0074this(...) and super(...) may only be called from a constructorthis(...)/super(...) 只能寫在建構子裡(可以是 JEP 513 允許的「super() 之前的敘述」之一,見 docs/language.md §4.2)。
TY-TYP-0075recursive constructor invocation建構子遞迴呼叫自己。

方法解析、lambda 與 pattern(0076–0094)

代碼訊息說明與修法
TY-TYP-0076cannot find method %s(%s)/cannot find method %s for this functional interface找不到方法:檢查名稱、參數型別、可見性,或受體型別。
TY-TYP-0077non-static method %s cannot be referenced from a type name用類別名稱只能呼叫靜態方法。
TY-TYP-0078cannot invoke %s on %s對這個型別呼叫方法不合法。
TY-TYP-0079%s has %s access in %s方法可見性不足。
TY-TYP-0080cannot find symbol %s in %s/on array成員不存在於該型別。
TY-TYP-0081cannot infer the functional interface for this lambda; declare the target type/cannot infer the functional interface for this method referencelambda/方法參照沒有目標型別,請明確指定。
TY-TYP-0082lambda target type must be a functional interface, found %s/method reference target type must be a functional interface目標型別不是介面。
TY-TYP-0083%s is not a functional interface介面有多個抽象方法,不能當 lambda 目標。
TY-TYP-0084lambda has %d parameters but %s requires %dlambda 參數數量不符。
TY-TYP-0085cannot construct %s建構子參照的目標不能建構。
TY-TYP-0086cannot resolve static import %s靜態 import 找不到對應成員。
TY-TYP-0087record pattern requires a record type, found %s解構 pattern 的左邊不是 record 型別(case Point(int x, int y) 的 Point 必須是 record)。
TY-TYP-0088record pattern for %s needs %d components, found %d解構的綁定數量與 record 成員數不符;巢狀解構也要逐一對上。
TY-TYP-0089'case null' requires a reference selectorcase null 只能用在參考型別的 switch 選擇子上,原生型別請改用 default。
TY-TYP-0090%s does not name a super interfaceInterface.super.method() 的 Interface 不存在或不是介面。
TY-TYP-0091%s is not a super interface of %s限定的 super 只能指向自己(直接或間接)實作的介面。
TY-TYP-0092a primitive pattern needs a name to bind the value to原生型別 pattern 一定要綁定變數:o instanceof int i,不能只寫 o instanceof int。
TY-TYP-0093boolean cannot be converted to %sboolean 只能和 boolean pattern 配對。
TY-TYP-0094primitive pattern %s needs a boxed value, found %s選擇子既不是參考型別也不是原生數值。
TY-IO-0101模組檔本身的錯誤(teyru.mod 無法解析、版本語法不對…)訊息來自 internal/mod,指出檔案與原因。
TY-IO-0102cannot read package %s: %v匯入的套件在模組快取裡找不到,或它的原始檔讀不出來。先跑 teyru mod tidy 或 teyru get。
TY-IO-0103teyru.sum 的雜湊不符快取裡的模組內容與 teyru.sum 記的不一樣。要嘛是依賴被改過,要嘛是快取被動過;建置會停下來而不是用下去。
TY-IO-0104%s declares package %s, but %s in the same directory declares %s同一個目錄裡的兩個檔案宣告了不同的套件。
TY-TYP-0095cannot infer the type arguments of %s(%s)泛型方法的型別引數推不出來:沒有帶型別的引數,也沒有目標型別可用(lambda 參數最常見)。寫出型別引數或給一個有型別的引數。
TY-TYP-0096switch expression does not cover all possible input valuesswitch 運算式必須窮盡:int/String 選擇子一定要有 default,列舉選擇子要涵蓋每一個常數。switch 陳述式不受此限。
TY-TYP-0097native methods %s and %s both need the C symbol %s兩個多載 native 方法編碼後得到同一個 C 符號(例如類別名 AI 與 int[])。改名或改參數型別。
TY-TYP-0098non-static %s cannot be referenced from a static contextlambda 主體用到撰寫處的 this(含未限定的實例方法呼叫、裸欄位名與 super),但 lambda 寫在 static 方法或 static 初始化區塊裡,沒有實例可捕獲。Java 同樣拒絕。
TY-TYP-0108(已移除)JSON 綁定改由執行期讀取類別,沒有「產生綁定」這個步驟。
TY-TYP-0109(已移除)同上:@SerializedName 造成的同名在讀取時才看得出來。
TY-TYP-0112(已移除)從 JSON 讀取的類別由執行期建立,建構子的限制改在 newInstance 時浮現。
TY-TYP-0111(已移除)controller 的回傳值一律由綁定寫成 JSON,沒有映射不了的型別。
TY-TYP-0110(已移除)欄位型別能不能綁定,是讀取時才知道的事。
TY-TYP-0114not a statement: %s has no effect沒有副作用的運算式陳述式(JLS 14.8)。這個語言在換行結束運算式,所以 long x = a 換行 + b 是兩個陳述式,第二個是安靜的一元加號——x 少一項而沒有任何訊息。現在會報出來。
TY-TYP-0113resource type %s is not a subtype of AutoCloseabletry-with-resources 的資源型別必須是 AutoCloseable 的子型別。隱含的 close() 是一次介面呼叫,所以「剛好有 close() 方法」的類別會編成物件沒有項目的 itable 呼叫,執行期才爆。
TY-TYP-0115cannot resolve import %s匯入路徑指不到任何東西。名字在 Teyru 裡是照簡單名稱找的,前面寫什麼套件都一樣,所以 import java.utli.List 這種拼錯的套件以前是安靜地被忽略、然後照樣拿到 List。現在匯入必須指向:標準程式庫回答的套件(teyru 本身,以及相容用的 java.util、com.google.gson、lombok…,見 docs/language.md §11)、本次建置某個檔案宣告的套件、或是一個完整名稱就是這條路徑的型別。
TY-TYP-0116incompatible types: %s cannot be converted to %s複合賦值的隱含轉型(JLS 15.26.2)在目標是裝箱型別時,只能是把「已經是該原生型別」的值裝箱:Integer a; a += 1 裝的是 int,而 Short s; s += 1 得把 int 裝進 Short——javac 就是把它當型別不符拒絕。這裡以前接受它,然後在產生程式碼時沒有對應的包裝可用。
TY-TYP-0117test method %s.%s …(例:test method T.m is static; @Test methods are instance methods)teyru test 找到的測試方法形狀不對:@Test/@BeforeEach/@AfterEach 是 static、有參數、是 private、沒有主體,或同一個方法標了多個測試標註。
TY-TYP-0118test class %s …(例:test class T is nested; tests must be top-level classes)帶有測試方法的類別不能被測試執行器建構:巢狀、抽象、沒有無參數建構子,或建構子是 private。
TY-TYP-0119invalid permits clause: %s is not a direct subtype of %spermits 子句指名了一個不是該 sealed 型別直接子型別的型別(間接子型別也不行,JLS 8.1.6)。
TY-TYP-0120subtype %s of sealed type %s must be listed in its permits clause一個直接子型別沒有出現在 permits 裡。沒有 permits 子句時,只有同一個編譯單元裡的直接子型別被隱式允許。
TY-TYP-0121permitted subtype %s of sealed type %s must be final, sealed, or non-sealedpermits 指名的子型別必須是 final、sealed 或 non-sealed 之一,否則它自己可以再被任意繼承。
TY-TYP-0122unreported exception %s; must be caught or declared to be thrown呼叫宣告 throws 的方法、建構子,或 throw 一個 checked 例外時,它必須被外層的 try 捕捉,或在目前的方法上宣告。標準庫自己的函式體目前豁免。
TY-TYP-0100(已移除)容器改讀類別之後,重名 bean 在 refresh() 時被拒絕。
TY-TYP-0101%s is declared by the framework and cannot be redefined__TeyruFramework 是容器註冊用的合成類別,名字被保留。
TY-TYP-0102@Bean method %s must not be static/@Bean method %s must return the bean's type/@Bean method %s does not return a class type@Bean 方法必須不是 static、且回傳型別是一個類別(基本型別會裝箱)。
TY-TYP-0103(已移除)缺少 bean 現在是 refresh() 時的例外——Spring 也是啟動時才發現。
TY-TYP-0104(已移除)兩個候選是 refresh() 時的例外,訊息裡帶著兩個名字。
TY-TYP-0105(已移除)建構子選擇改在執行期:標了 @Autowired 的、唯一的那個、或無參的那個。
TY-TYP-0106(已移除)@PostConstruct 的簽章改在呼叫時才檢查。
TY-TYP-0107(已移除)相依成環是 refresh() 時的例外,訊息裡有環。
TY-TYP-0099reference to %s is ambiguous: it is declared in both %s and %s兩個 import p.* 都提供同一個簡單名稱(JLS 6.5.5.1)。寫出完整名稱或用單一類型匯入(import a.Widget)消歧義。

TY-PROP:原生 property

代碼訊息說明與修法
TY-PROP-0001a property declaration must declare exactly one name一個 property 只能宣告一個名稱。
TY-PROP-0002duplicate get accessor/duplicate set accessorget/set 各只能出現一次。
TY-PROP-0003computed property %s cannot use storage modifiers沒有儲存的 property 不能用 final/volatile/transient。
TY-PROP-0004final property %s cannot declare a setterfinal property 不能有 setter。
TY-PROP-0005property %s has no getter只有 setter 的 property 不能被讀取;在 accessor 內請用 field。
TY-PROP-0007property %s has no setter只有 getter 的 property 不能被指派。
TY-PROP-0008property %s needs a getter for compound assignmentp.x += 1 需要 getter 與 setter。

TY-INT 與 TY-IO

代碼訊息說明
TY-INT-0001prelude is missing class %s前導程式庫損壞或類別被覆蓋,屬於編譯器內部錯誤。
TY-INT-0002unsupported expression %T語意分析遇到未處理的節點,屬於編譯器內部錯誤(請回報)。
TY-INT-0004@Singular goes on a builder field, not on the class寫在類別上沒有意義。
TY-INT-0005@Singular needs a List or Map field, found %s@Singular 只能用在集合欄位。
TY-INT-0006@CustomLog needs %s in a %s file in the source file's directory or above it/@CustomLog cannot pass TYPE: …/@CustomLog: cannot resolve the factory class %q named by %s@CustomLog 要靠 lombok.config 的 lombok.log.custom.declaration 才知道怎麼建 logger(讀法見 docs/lombok.md):沒有這個鍵、樣式用了 TYPE、或樣式指的類別找不到,都在這裡報。也可以改用 @Log 或自己宣告欄位。
TY-INT-0100<建構>: <原因>, in <位置>(例:an inner class (Main$Local$2): the llvm back end does not lower the enclosing-instance chain, in Main.instanceLocal)--backend=llvm 對它降不下去的建構具名拒絕,訊息說出碰到的是什麼、為什麼、在哪裡,而不是安靜地退回 C 後端。要用 C 後端就不要加 --backend=llvm
TY-INT-0101the llvm back end compiles for linux/amd64 only (%s was asked for); use the c back end for other platformsLLVM 後端只編 linux/amd64;其他目標請用 C 後端
TY-INT-0102cannot emit Java for <特性>: <原因>(例:cannot emit Java for the native property years: Java has no property syntax: …)teyru emit-java 遇到寫不成 Java 的 Teyru 特性時拒絕,訊息指名那個特性與原因。印出來的 Java 要能編就改寫那個特性
TY-INT-0103the llvm back end does not emit debug information yet: -g is supported by the c back end only--backend llvm -g:LLVM 後端還不產生 DWARF,與其安靜地忽略 -g,不如指名拒絕。
TY-IO-0001cannot read %s: %v來源檔讀不到,檢查路徑與權限。

執行期錯誤

執行期的失敗不是診斷碼,而是 Throwable 家族:

例外觸發時機
NullPointerException對 null 拆箱,或讀寫欄位、呼叫方法(String 的方法、clone()、介面方法與虛擬呼叫都是)、讀寫陣列元素或取 length
ArrayIndexOutOfBoundsException陣列索引超出 [0, length)(讀與寫都是;null 陣列先丟 NullPointerException);Arrays.copyOfRange 那類範圍引數越界也用它
StringIndexOutOfBoundsException字串與 StringBuilder 的索引或範圍超出:charAt、substring、delete、StringBuilder.insert 等(String 的每一個邊界檢查都是這一個)
IndexOutOfBoundsException容器自己的索引,例如 ArrayList.get/set/remove 的索引超出 [0, size)
NoSuchElementException已經沒有元素卻再呼叫 Iterator.next()
ArithmeticException整數除以零或取餘數為零
ClassCastExceptioncast 或 instanceof 失敗的強制轉型
NegativeArraySizeException陣列長度為負
AssertionErrorassert 失敗
IllegalArgumentExceptionenum.valueOf 找不到常數等

越界那三個的繼承階層與 Java 相同:IndexOutOfBoundsException 是父類別, ArrayIndexOutOfBoundsException 與 StringIndexOutOfBoundsException 在它底下,所以 catch (IndexOutOfBoundsException e) 接得到三種。這也是 Java 程式碼裡最常見的寫法, 它在這裡與在 Java 一樣有效(見 docs/language.md §10)。

沒有被 catch 的例外會印出 Exception in thread "main" … 並以狀態 1 結束。 若執行到沒有實作的抽象方法,會印出 teyru: no implementation for … 並以狀態 70 結束。

本頁目錄