-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from moonbitlang/haoxiang/add-error-codes-index
feat: add error codes index
- Loading branch information
Showing
204 changed files
with
991 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# E0001 | ||
|
||
There is an internal error occurred to the compiler. Usually this means you have | ||
discovered a bug in the compiler. | ||
|
||
A bug report containing the error description and relevant code would be | ||
greatly appreciated. You can submit the bug report here: | ||
|
||
<https://github.com/moonbitlang/moonbit-docs/issues/new?labels=bug,ICE> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1001 | ||
|
||
Unused function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1002 | ||
|
||
Unused variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1003 | ||
|
||
Unused type declaration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1004 | ||
|
||
Unused abstract type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1005 | ||
|
||
Unused generic type variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1006 | ||
|
||
Variant is unused. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1007 | ||
|
||
Field is never read. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1008 | ||
|
||
The modifier is redundant here since field is modifier by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1009 | ||
|
||
The struct is never constructed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1010 | ||
|
||
Unused pattern. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1011 | ||
|
||
Partial match. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1012 | ||
|
||
Unreachable code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1013 | ||
|
||
The type of this expression contains unresolved type variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1014 | ||
|
||
Type name should be capitalized. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1015 | ||
|
||
The mutability is never used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1016 | ||
|
||
Parser consistency check failed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1018 | ||
|
||
There is no [continue] in this loop expression, so [loop] is useless here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1019 | ||
|
||
Toplevel declaration is not left aligned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1020 | ||
|
||
Invalid pragma. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1021 | ||
|
||
Some arguments of constructor are omitted in pattern. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1022 | ||
|
||
Ambiguous block expression. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1023 | ||
|
||
The body of this try expression never raises any error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1024 | ||
|
||
The error type of this function is never used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1026 | ||
|
||
The patterns are complete so the usage of `catch!` is useless. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1027 | ||
|
||
The syntax is deprecated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1028 | ||
|
||
Unfinished code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1029 | ||
|
||
Unused package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1030 | ||
|
||
The package alias is empty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1031 | ||
|
||
The optional argument is never supplied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1032 | ||
|
||
Default value of optional argument is unused. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1033 | ||
|
||
The import value is never used directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1034 | ||
|
||
The syntax `~label` is deprecated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1035 | ||
|
||
The word is reserved for possible future use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1036 | ||
|
||
The label name shadows a label name that is already in scope. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1037 | ||
|
||
The label name is never used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1038 | ||
|
||
Useless guard because the pattern is irrefutable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1039 | ||
|
||
Method name conflicts with another definition. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E1040 | ||
|
||
Calling this kind of method directly via name(..) is deprecated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# E2000 | ||
|
||
The usage of function (type, trait, etc.) is flagged with alert. Usually, alert | ||
message comes with a alert kind and a detailed description of the alert. If you | ||
are using the function from a library, these alerts are set by the library | ||
author to provide some more information on the usage of the function | ||
|
||
There are some common alerts that you may encounter: | ||
|
||
* `deprecated`: indicates the function (type, trait, etc) is deprecated and | ||
should not be used or migrate to new APIs. | ||
* `unsafe`: indicates this API panics, breaks internal invariants, has undefined | ||
behavior under some circumstances. The concrete semantics of this kind of | ||
alerts may be different across packages, and please consult the documentation | ||
or the author of these packages for further details. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
/// @alert deprecated "Use `greet` instead" | ||
fn greeting() -> String { | ||
"Hello!" | ||
} | ||
fn greet(name~ : String = "") -> String { | ||
if name != "" { | ||
"Hello!" | ||
} else { | ||
"Hello, \{name}!" | ||
} | ||
} | ||
fn main() -> Unit { | ||
println(greeting()) | ||
// ^~~~~~~~ Warning (Alert deprecated): Use `greet` instead(2000) | ||
} | ||
``` | ||
|
||
## Suggestion | ||
|
||
One way to fix the alert, is to change your code as suggested by the message (like `deprecated`): | ||
|
||
```moonbit | ||
// ... code in the example above ... | ||
fn main() -> Unit { | ||
println(greet(name="world")) | ||
} | ||
``` | ||
|
||
If you clearly know what you are doing and would like to suppress the alert, you can change the `moon.pkg.json` file for packages where you would like to disable **this kind of alert**. For example: | ||
|
||
```moonbit | ||
{ | ||
// ... other fields in the file | ||
"alert-list": "-deprecated" | ||
} | ||
``` | ||
|
||
NOTE: There is no way to disable alerts for a line/file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E3001 | ||
|
||
Lexing error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# E3002 | ||
|
||
Parse error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# E3003 | ||
|
||
`init` and `main` function must have no arguments and no return value. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
fn main() -> Unit { | ||
println("Hello, world!") | ||
} | ||
``` | ||
|
||
## Suggestion | ||
|
||
Remove the argument list and return type annotation, as: | ||
|
||
```moonbit | ||
fn main { | ||
println("Hello, world!") | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# E3004 | ||
|
||
Missing parameters list. Add `()` after the name of the function if it takes 0 | ||
parameter. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
fn greet { | ||
println("Hello, world!") | ||
} | ||
``` | ||
|
||
## Suggestion | ||
|
||
Add `()` after the function name. | ||
|
||
```moonbit | ||
fn greet() { | ||
println("Hello, world!") | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# E3005 | ||
|
||
There is no such visibility for the entity (function/type/trait/...). | ||
|
||
Usually, this means that you put an `priv` visibility modifier on a entity is | ||
by-default private. | ||
|
||
See the [Access | ||
Control](https://docs.moonbitlang.com/en/latest/language/packages.html#access-control) | ||
section of [MoonBit Language | ||
Documentation](https://docs.moonbitlang.com/en/latest/language/index.html) for a | ||
detailed explanaion on the visibility in MoonBit. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
priv let value = 3 | ||
``` | ||
|
||
## Suggestion | ||
|
||
Remove the visibility modifier from the definition of the entity: | ||
|
||
```moonbit | ||
let value = 3 // This is already `priv` by default. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# E3006 | ||
|
||
There is no individual visibility control fro enum constructors. | ||
|
||
Usually, this means that you put an `priv` or `pub` visibility modifier on a enum constructor. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
enum A { | ||
priv A1 | ||
pub A2 | ||
} | ||
``` | ||
|
||
## Suggestion | ||
|
||
Remove the visibility modifier from the definition of the enum constructor: | ||
|
||
```moonbit | ||
enum A { | ||
A1 | ||
A2 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# E3007 | ||
|
||
Wrong location of `..` in pattern match. Put `..` at the end of the pattern. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
let {a, .., c} = s | ||
``` | ||
|
||
## Suggestion | ||
|
||
```moonbit | ||
let {a, c, ..} = s | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# E3008 | ||
|
||
There are multiple `..` patterns in array pattern. Remove until there is only one `..` pattern in array pattern. | ||
|
||
## Erroneous example | ||
|
||
```moonbit | ||
let [fst, .., .., snd] = array | ||
``` | ||
|
||
## Suggestion | ||
|
||
Remove the extra `..` pattern. | ||
|
||
```moonbit | ||
let [fst, .., snd] = array | ||
``` |
Oops, something went wrong.