Browse Source

added $field check to Typer

Simon Krajewski 12 years ago
parent
commit
1dd0c598c4
2 changed files with 2 additions and 1 deletions
  1. 0 1
      parser.ml
  2. 2 0
      typer.ml

+ 0 - 1
parser.ml

@@ -827,7 +827,6 @@ and expr_next e1 = parser
 		if is_resuming p then display (EDisplay (e1,false),p);
 		if is_resuming p then display (EDisplay (e1,false),p);
 		(match s with parser
 		(match s with parser
 		| [< '(Const (Ident f),p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,f) , punion (pos e1) p2) s
 		| [< '(Const (Ident f),p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,f) , punion (pos e1) p2) s
-		(* TODO: we have to limit this to the reification case *)
 		| [< '(Dollar v,p2); s >] -> expr_next (EField (e1,"$"^v) , punion (pos e1) p2) s
 		| [< '(Dollar v,p2); s >] -> expr_next (EField (e1,"$"^v) , punion (pos e1) p2) s
 		| [< '(Binop OpOr,p2) when do_resume() >] -> display (EDisplay (e1,false),p) (* help for debug display mode *)
 		| [< '(Binop OpOr,p2) when do_resume() >] -> display (EDisplay (e1,false),p) (* help for debug display mode *)
 		| [< >] ->
 		| [< >] ->

+ 2 - 0
typer.ml

@@ -1984,6 +1984,8 @@ and type_expr ctx ?(need_val=true) (e,p) =
 	| EField ((EConst (String s),p),"code") ->
 	| EField ((EConst (String s),p),"code") ->
 		if UTF8.length s <> 1 then error "String must be a single UTF8 char" p;
 		if UTF8.length s <> 1 then error "String must be a single UTF8 char" p;
 		mk (TConst (TInt (Int32.of_int (UChar.code (UTF8.get s 0))))) ctx.t.tint p
 		mk (TConst (TInt (Int32.of_int (UChar.code (UTF8.get s 0))))) ctx.t.tint p
+	| EField(_,n) when n.[0] = '$' ->
+		error "Field names starting with $ are not allowed" p
 	| EField _
 	| EField _
 	| EArray _
 	| EArray _
 	| EConst (Ident _) ->
 	| EConst (Ident _) ->