Skip to content

Commit 043982b

Browse files
committed
ClojureScriptLanguage: decode unbound vars to null
This is common when, e.g., a script has no declared outputs, does not assign a value to the "result" variable, and has no return value. For example, the following script: (let [n 23] (println n)) was issuing the warning: [WARNING] Ignoring unsupported output: result [clojure.lang.Var$Unbound] When really, the return value there should be null and hence ignored.
1 parent 19db479 commit 043982b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/scijava/plugins/scripting/clojure/ClojureScriptLanguage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import org.scijava.script.AbstractScriptLanguage;
4141
import org.scijava.script.ScriptLanguage;
4242

43+
import clojure.lang.Var;
44+
4345
/**
4446
* An adapter of the Clojure interpreter to the SciJava scripting interface.
4547
*
@@ -64,4 +66,9 @@ public ScriptEngine getScriptEngine() {
6466
return new ClojureScriptEngine();
6567
}
6668

69+
@Override
70+
public Object decode(final Object object) {
71+
if (object instanceof Var.Unbound) return null;
72+
return object;
73+
}
6774
}

0 commit comments

Comments
 (0)