julia: Fix exception on literal empty list
authorDov Murik <dov.murik@gmail.com>
Wed, 30 Mar 2016 13:18:07 +0000 (09:18 -0400)
committerDov Murik <dov.murik@gmail.com>
Wed, 30 Mar 2016 13:18:38 +0000 (09:18 -0400)
Issue #190

julia/step3_env.jl
julia/step4_if_fn_do.jl
julia/step5_tco.jl
julia/step6_file.jl
julia/step7_quote.jl
julia/step8_macros.jl
julia/step9_try.jl
julia/stepA_mal.jl

index c0bcde1..91f80ca 100755 (executable)
@@ -26,6 +26,7 @@ end
 
 function EVAL(ast, env)
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     # apply
     if     :def! == ast[1]
index 5f98d86..0e33713 100755 (executable)
@@ -27,6 +27,7 @@ end
 
 function EVAL(ast, env)
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     # apply
     if     :def! == ast[1]
index eeefb99..6869048 100755 (executable)
@@ -30,6 +30,7 @@ function EVAL(ast, env)
   while true
     #println("EVAL: $(printer.pr_str(ast,true))")
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     # apply
     if     :def! == ast[1]
index 7e0ce14..83246ff 100755 (executable)
@@ -30,6 +30,7 @@ function EVAL(ast, env)
   while true
     #println("EVAL: $(printer.pr_str(ast,true))")
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     # apply
     if     :def! == ast[1]
index 5c4cb7b..79dd652 100755 (executable)
@@ -46,6 +46,7 @@ function EVAL(ast, env)
   while true
     #println("EVAL: $(printer.pr_str(ast,true))")
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     # apply
     if     :def! == ast[1]
index 92117f3..e7b42c7 100755 (executable)
@@ -32,6 +32,7 @@ end
 
 function ismacroCall(ast, env)
     return isa(ast, Array) &&
+           !isempty(ast) &&
            isa(ast[1], Symbol) &&
            env_find(env, ast[1]) != nothing &&
            isa(env_get(env, ast[1]), MalFunc) &&
@@ -66,6 +67,7 @@ function EVAL(ast, env)
     # apply
     ast = macroexpand(ast, env)
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     if     :def! == ast[1]
         return env_set(env, ast[2], EVAL(ast[3], env))
index 5a37fa6..868069a 100755 (executable)
@@ -32,6 +32,7 @@ end
 
 function ismacroCall(ast, env)
     return isa(ast, Array) &&
+           !isempty(ast) &&
            isa(ast[1], Symbol) &&
            env_find(env, ast[1]) != nothing &&
            isa(env_get(env, ast[1]), MalFunc) &&
@@ -66,6 +67,7 @@ function EVAL(ast, env)
     # apply
     ast = macroexpand(ast, env)
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     if     :def! == ast[1]
         return env_set(env, ast[2], EVAL(ast[3], env))
index 3ca25bc..1f897cb 100755 (executable)
@@ -32,6 +32,7 @@ end
 
 function ismacroCall(ast, env)
     return isa(ast, Array) &&
+           !isempty(ast) &&
            isa(ast[1], Symbol) &&
            env_find(env, ast[1]) != nothing &&
            isa(env_get(env, ast[1]), MalFunc) &&
@@ -66,6 +67,7 @@ function EVAL(ast, env)
     # apply
     ast = macroexpand(ast, env)
     if !isa(ast, Array) return eval_ast(ast, env) end
+    if isempty(ast) return ast end
 
     if     :def! == ast[1]
         return env_set(env, ast[2], EVAL(ast[3], env))