-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add error code desc; use dedicated exception Undecided
- Loading branch information
Showing
6 changed files
with
63 additions
and
5 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
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,44 @@ | ||
# M0200 | ||
|
||
This error means that the compiler encountered a subtyping, equivalence or constructor equivalence problem that it cannot decide is true or false in a timely manner. | ||
|
||
This is due to a limitation of the type system and may require you to rewrite | ||
some of your code to avoid the problem. | ||
|
||
The most like cause is a recursive type or class whose definition involves | ||
instantiating the type or class with nested type parameters. | ||
|
||
For example, this definition of `Box<T>` | ||
|
||
``` motoko | ||
class Box<T>(v : T) { | ||
public let value = t; | ||
public func map<R>(f : T -> R) : Box<R> { | ||
Box<R>(f t) | ||
}; | ||
} | ||
``` | ||
is problematic because `Box<R>` is instantiated at `R`, an inner type parameter, while | ||
|
||
``` motoko | ||
class Box<T>(v : T) { | ||
public let value = v; | ||
public func map(f : T -> T) : Box<T> { | ||
Box<T>(f value) | ||
}; | ||
} | ||
``` | ||
is accepted (but also less useful). | ||
|
||
Another workaround is to define the problematic method as a separate | ||
function, outside of the class: | ||
|
||
``` motoko | ||
class Box<T>(v : T) { | ||
public let value = v | ||
}; | ||
func map<T, R>(b : Box<T>, f : T -> R) : Box<R> { | ||
Box<R>(f (b.value)) | ||
}; | ||
``` |
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
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
polyrec.mo:4.10-11.4: type error [M0XXX], can't determine type constructor equality? | ||
polyrec.mo:4.10-11.4: type error [M0200], cannot decide type constructor equality |