class a:Enum {
function fromEnum(x:a) -> Word;
}
data Color = R | G | B
instance Color : Enum {
function fromEnum(c) {
match c {
| R => return 1;
| G => return 2;
| B => return 3;
};
}
}
data Bool = False | True
instance Bool : Enum {
function fromEnum(b) {
match b {
| R => return 0;
| G => return 1;
};
}
}
contract BadInstance {
function main() { return fromEnum(True);}
}
EXPECTED: the Bool : Enum instance should be rejected as itsfromEnum method has type Color -> Word rather than Bool -> Word.
ACTUAL: typechecker accepts the program (and later phases make a mess, because the well-typedness assumption is false)
Consider
EXPECTED: the
Bool : Enum
instance should be rejected as itsfromEnum
method has typeColor -> Word
rather thanBool -> Word
.ACTUAL: typechecker accepts the program (and later phases make a mess, because the well-typedness assumption is false)