Skip to content

Commit

Permalink
Merge pull request #444 from moonbitlang/haoxiang/add-error-codes-index
Browse files Browse the repository at this point in the history
feat: add error codes index
  • Loading branch information
tonyfettes authored Feb 6, 2025
2 parents 192a6dc + c046728 commit ba2a876
Show file tree
Hide file tree
Showing 204 changed files with 991 additions and 0 deletions.
9 changes: 9 additions & 0 deletions next/language/error_codes/E0001.md
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>
3 changes: 3 additions & 0 deletions next/language/error_codes/E1001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1001

Unused function.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1002

Unused variable.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1003.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1003

Unused type declaration.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1004.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1004

Unused abstract type.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1005.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1005

Unused generic type variable.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1006.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1006

Variant is unused.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1007.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1007

Field is never read.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1008.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1009.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1009

The struct is never constructed.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1010.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1010

Unused pattern.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1011.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1011

Partial match.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1012.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1012

Unreachable code.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1013.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1013

The type of this expression contains unresolved type variables.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1014.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1014

Type name should be capitalized.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1015.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1015

The mutability is never used.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1016.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1016

Parser consistency check failed.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1018.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1019.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1019

Toplevel declaration is not left aligned.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1020.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1020

Invalid pragma.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1021.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1021

Some arguments of constructor are omitted in pattern.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1022.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1022

Ambiguous block expression.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1023.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1024.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1024

The error type of this function is never used.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1026.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1027.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1027

The syntax is deprecated.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1028.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1028

Unfinished code.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1029

Unused package.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1030.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1030

The package alias is empty.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1031.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1031

The optional argument is never supplied.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1032.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1032

Default value of optional argument is unused.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1033.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1033

The import value is never used directly.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1034.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1034

The syntax `~label` is deprecated.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1035.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1035

The word is reserved for possible future use.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1036.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1037.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1037

The label name is never used.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1038.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1038

Useless guard because the pattern is irrefutable.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1039.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E1039

Method name conflicts with another definition.
3 changes: 3 additions & 0 deletions next/language/error_codes/E1040.md
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.
59 changes: 59 additions & 0 deletions next/language/error_codes/E2000.md
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.
3 changes: 3 additions & 0 deletions next/language/error_codes/E3001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E3001

Lexing error
3 changes: 3 additions & 0 deletions next/language/error_codes/E3002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# E3002

Parse error
21 changes: 21 additions & 0 deletions next/language/error_codes/E3003.md
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!")
}
```
22 changes: 22 additions & 0 deletions next/language/error_codes/E3004.md
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!")
}
```
26 changes: 26 additions & 0 deletions next/language/error_codes/E3005.md
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.
```
25 changes: 25 additions & 0 deletions next/language/error_codes/E3006.md
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
}
```
15 changes: 15 additions & 0 deletions next/language/error_codes/E3007.md
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
```
17 changes: 17 additions & 0 deletions next/language/error_codes/E3008.md
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
```
Loading

0 comments on commit ba2a876

Please sign in to comment.