reject path variable nesting explicitly;
authorwenzelm
Fri, 03 Aug 2012 13:06:25 +0200
changeset 48658 4c7932270d6d
parent 48657 63ef2f0cf8bb
child 48659 40a87b4dac19
child 48660 730ca503e955
reject path variable nesting explicitly;
src/Pure/General/path.ML
src/Pure/General/path.scala
--- a/src/Pure/General/path.ML	Fri Aug 03 12:37:31 2012 +0200
+++ b/src/Pure/General/path.ML	Fri Aug 03 13:06:25 2012 +0200
@@ -179,7 +179,12 @@
 
 (* expand variables *)
 
-fun eval (Variable s) = rep (explode_path (getenv_strict s))
+fun eval (Variable s) =
+      let val path = explode_path (getenv_strict s) in
+        if exists (fn Variable _ => true | _ => false) (rep path) then
+          error ("Illegal path variable nesting: " ^ s ^ "=" ^ print path)
+        else rep path
+      end
   | eval x = [x];
 
 val expand = rep #> maps eval #> norm #> Path;
--- a/src/Pure/General/path.scala	Fri Aug 03 12:37:31 2012 +0200
+++ b/src/Pure/General/path.scala	Fri Aug 03 13:06:25 2012 +0200
@@ -167,7 +167,10 @@
     def eval(elem: Path.Elem): List[Path.Elem] =
       elem match {
         case Path.Variable(s) =>
-          Path.explode(Isabelle_System.getenv_strict(s)).elems
+          val path = Path.explode(Isabelle_System.getenv_strict(s))
+          if (path.elems.exists(_.isInstanceOf[Path.Variable]))
+            error ("Illegal path variable nesting: " + s + "=" + path.toString)
+          else path.elems
         case x => List(x)
       }