@@ -51,7 +51,7 @@ use ast::{struct_variant_kind, subtract};
5151use ast:: { sty_box, sty_region, sty_static, sty_uniq, sty_value} ;
5252use ast:: { token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok} ;
5353use ast:: { tt_nonterminal, tuple_variant_kind, Ty , ty_, ty_bot, ty_box} ;
54- use ast:: { TypeField , ty_fixed_length_vec, ty_closure, ty_bare_fn} ;
54+ use ast:: { TypeField , ty_fixed_length_vec, ty_closure, ty_bare_fn, ty_typeof } ;
5555use ast:: { ty_infer, TypeMethod } ;
5656use ast:: { ty_nil, TyParam , TyParamBound , ty_path, ty_ptr, ty_rptr} ;
5757use ast:: { ty_tup, ty_u32, ty_uniq, ty_vec, uniq} ;
@@ -1105,6 +1105,13 @@ impl Parser {
11051105 let result = self . parse_ty_closure ( ast:: BorrowedSigil , None ) ;
11061106 self . obsolete ( * self . last_span , ObsoleteBareFnType ) ;
11071107 result
1108+ } else if self . eat_keyword ( keywords:: Typeof ) {
1109+ // TYPEOF
1110+ // In order to not be ambiguous, the type must be surrounded by parens.
1111+ self . expect ( & token:: LPAREN ) ;
1112+ let e = self . parse_expr ( ) ;
1113+ self . expect ( & token:: RPAREN ) ;
1114+ ty_typeof ( e)
11081115 } else if * self . token == token:: MOD_SEP
11091116 || is_ident_or_path ( self . token ) {
11101117 // NAMED TYPE
0 commit comments