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:
Graydon Hoare 2010-07-19 13:25:04 -07:00
parent f1db420317
commit 1f0656d908
2 changed files with 14 additions and 3 deletions

View File

@ -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

View 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);
}