]> hydra-www.ietfng.org Git - dyna2/commitdiff
Error when user tries to iterate over something which is not a list (e.g. using
authorTim Vieira <tim.f.vieira@gmail.com>
Wed, 3 Jul 2013 03:16:58 +0000 (23:16 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Wed, 3 Jul 2013 03:16:58 +0000 (23:16 -0400)
'in' operator).

src/Dyna/Backend/Python/Backend.hs
src/Dyna/Backend/Python/stdlib.py

index 2de761739f2b17c64085056be421a752f241f5c4..e48e3d35fd2dd38fd017034c0e328bd94dcc9dd4 100644 (file)
@@ -125,7 +125,7 @@ builtins (f,is,o) = case () of
     -> case is of
          [x,y] | isFree x && isGround y
                -> let
-                    call _ vs = "iter" <> (parens $ sepBy comma $ mpv vs) <> colon -- for some reason on colon get put at the end of this line.
+                    call _ vs = "iter_cons" <> (parens $ sepBy comma $ mpv vs) <> colon -- for some reason on colon get put at the end of this line.
                     cdop = [OPIter x [y] "iter" DetNon (Just $ PDBS call)]
                     cmod = [(x^.mv_var, nuniv)]
                   in if isFree o
index 9c0d2d11483c817bcea18856f987807df066efcb..f5d296501133ed91a6262f1de0fb0032edf4c69b 100644 (file)
@@ -51,3 +51,8 @@ def _todynalist(x):
 
 def get(x, i):
     return x[i]
+
+def iter_cons(x):
+    if not (isinstance(x, Cons) or x is Nil):
+        raise TypeError("Attemping to iterate something which isn't a list.")
+    return x