mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 17:42:47 +00:00
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
@ -261,9 +261,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
else
|
||||
LTYPE_poly ((Array.map (fun p -> p.Common.node) params), ty)
|
||||
| Ast.MOD_ITEM_type _ ->
|
||||
Common.bug
|
||||
()
|
||||
"internal_check_mod_item_decl: unexpected mod item type"
|
||||
Common.err None "Type-item used in non-type context"
|
||||
in
|
||||
|
||||
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…
Reference in New Issue
Block a user