Skip to content

Commit d585030

Browse files
puredangerrichhickey
authored andcommitted
CLJ-2427 CompilerException toString() throws when RT not yet initialized
Signed-off-by: Rich Hickey <richhickey@gmail.com>
1 parent 88eca12 commit d585030

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/jvm/clojure/lang/Compiler.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -6875,21 +6875,19 @@ public static String makeMsg(String source, int line, int column, Symbol sym, Ke
68756875
line + ":" + column + ").";
68766876
}
68776877

6878-
private static boolean isSpecError(Throwable t) {
6879-
return (t instanceof IExceptionInfo) && RT.get(((IExceptionInfo) t).getData(), SPEC_PROBLEMS) != null;
6880-
}
6881-
68826878
public String toString(){
68836879
Throwable cause = getCause();
68846880
if(cause != null) {
6885-
if(RT.get(data, ERR_PHASE) == PHASE_MACRO_SYNTAX_CHECK && isSpecError(cause)) {
6886-
return String.format("%s", getMessage());
6887-
} else {
6888-
return String.format("%s%n%s", getMessage(), cause.getMessage());
6881+
if (cause instanceof IExceptionInfo) {
6882+
IPersistentMap data = (IPersistentMap)((IExceptionInfo)cause).getData();
6883+
if(PHASE_MACRO_SYNTAX_CHECK.equals(data.valAt(ERR_PHASE)) && data.valAt(SPEC_PROBLEMS) != null) {
6884+
return String.format("%s", getMessage());
6885+
} else {
6886+
return String.format("%s%n%s", getMessage(), cause.getMessage());
6887+
}
68896888
}
6890-
} else {
6891-
return getMessage();
68926889
}
6890+
return getMessage();
68936891
}
68946892
}
68956893

test/clojure/test_clojure/evaluation.clj

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
;; Created 22 October 2008
1616

1717
(ns clojure.test-clojure.evaluation
18-
(:use clojure.test))
18+
(:use clojure.test clojure.test-helper))
1919

2020
(import '(java.lang Boolean)
2121
'(clojure.lang Compiler Compiler$CompilerException))
@@ -116,16 +116,16 @@
116116

117117
(test-that
118118
"It is an error if there is no global var named by the symbol"
119-
(throws-with-msg
120-
#"(?s).*Unable to resolve symbol: bar.*" (eval 'bar)))
119+
(is (thrown-with-cause-msg? Compiler$CompilerException
120+
#"(?s).*Unable to resolve symbol: bar.*"
121+
(eval 'bar))))
121122

122123
(test-that
123124
"It is an error if the symbol reference is to a non-public var in a
124125
different namespace"
125-
(throws-with-msg
126-
#"(?s).*resolution-test/baz is not public.*"
127-
(eval 'resolution-test/baz)
128-
Compiler$CompilerException))
126+
(is (thrown-with-cause-msg? Compiler$CompilerException
127+
#"(?s).*resolution-test/baz is not public.*"
128+
(eval 'resolution-test/baz))))
129129

130130
(test-that
131131
"If a symbol is package-qualified, its value is the Java class named by the

0 commit comments

Comments
 (0)