Add a test for an obvious-seeming (but not actually legal) kind of cast attempted in issue #115, downgrade bug to an err in type.ml so you get a better message.
This commit is contained in:
parent
f1db420317
commit
1f0656d908
2 changed files with 14 additions and 3 deletions
|
@ -261,9 +261,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
else
|
else
|
||||||
LTYPE_poly ((Array.map (fun p -> p.Common.node) params), ty)
|
LTYPE_poly ((Array.map (fun p -> p.Common.node) params), ty)
|
||||||
| Ast.MOD_ITEM_type _ ->
|
| Ast.MOD_ITEM_type _ ->
|
||||||
Common.bug
|
Common.err None "Type-item used in non-type context"
|
||||||
()
|
|
||||||
"internal_check_mod_item_decl: unexpected mod item type"
|
|
||||||
in
|
in
|
||||||
|
|
||||||
let rec internal_check_base_lval
|
let rec internal_check_base_lval
|
||||||
|
|
13
src/test/compile-fail/constructor-as-cast.rs
Normal file
13
src/test/compile-fail/constructor-as-cast.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// error-pattern: non-type context
|
||||||
|
type base =
|
||||||
|
obj {
|
||||||
|
fn foo();
|
||||||
|
};
|
||||||
|
obj derived() {
|
||||||
|
fn foo() {}
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
fn main() {
|
||||||
|
let derived d = derived();
|
||||||
|
let base b = base(d);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue