Skip to content

Commit

Permalink
Add a test for an obvious-seeming (but not actually legal) kind of ca…
Browse files Browse the repository at this point in the history
…st attempted in issue rust-lang#115, downgrade bug to an err in type.ml so you get a better message.
  • Loading branch information
graydon committed Jul 19, 2010
1 parent f1db420 commit 1f0656d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/boot/me/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/test/compile-fail/constructor-as-cast.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 1f0656d

Please sign in to comment.