[Ur] last type decl wins?

Adam Chlipala adamc at impredicative.com
Tue Apr 12 21:13:02 EDT 2011


Marc Weber wrote:
> Should this be rejected?
>
> You can put this into a .ur file top level and still compile it!?
>
> type type_int = int
> val y:type_int = 2
> type type_int = string
> val x:type_int = "o"
>
> type_int is assigned int and string!
>
> Or am I totally missunderstanding something here?
>    

This behavior is just as in ML or Haskell.  You are shadowing a 
definition, but the old definition doesn't "go away," it just becomes 
impossible to reference.  At the end of the file, [y] has a type that 
refers to an out-of-scope identifier, but that isn't problematic 
semantically.



More information about the Ur mailing list