clojure/clojure · error

Unknown symbolic value: ##

Error message

Unknown symbolic value: ##

What it means

Sentinel in LispReader's SymbolicValueReader: the symbol following ## must be Inf, -Inf, or NaN; anything else has no entry in the specials map and reading fails. At-fault input: an unknown symbolic constant such as ##Infinity or ##foo.

Solutions

  1. Use the exact spellings ##Inf, ##-Inf, or ##NaN
  2. Spell out alternatives in code instead: (Double/POSITIVE_INFINITY) or (/ 1.0 0.0) for infinity
  3. Remove ## where a regular symbol was intended

Example fix

// before
(def x ##Infinity)
// after
(def x ##Inf)
Defensive patterns

Strategy: validation

Validate before calling

(def valid-specials #{"##Inf" "##-Inf" "##NaN"})
(defn known-special? [s] (contains? valid-specials s))

Try / catch

(try (read-string s)
  (catch Exception e
    (throw (ex-info "Unknown ## symbolic value" {:input s} e))))

Prevention

When it happens

Trigger: Reading ##Infinity, ##inf, ##Foo, or any symbol other than the three recognized specials after the ## dispatch prefix.

Common situations: Typing ##Infinity expecting it to work like ##Inf; trying to define custom ## symbols; confusion between ##Inf and Double/POSITIVE_INFINITY in other languages.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of clojure/clojure@f3b143341d (2026-09-09). Data as JSON: /api/errors/826c1220bbd70a69. Report an issue: GitHub.

Appendix: source

Thrown at src/jvm/clojure/lang/LispReader.java:764

		return RT.map(a);
	}
}


public static class SymbolicValueReader extends AFn{

    static IPersistentMap  specials = PersistentHashMap.create(Symbol.intern("Inf"), Double.POSITIVE_INFINITY,
                                                               Symbol.intern("-Inf"), Double.NEGATIVE_INFINITY,
                                                               Symbol.intern("NaN"), Double.NaN);

	public Object invoke(Object reader, Object quote, Object opts, Object pendingForms) {
		PushbackReader r = (PushbackReader) reader;
		Object o = read(r, true, null, true, opts, ensurePending(pendingForms));

		if (!(o instanceof Symbol))
			throw Util.runtimeException("Invalid token: ##" + o);
		if (!(specials.containsKey(o)))
			throw Util.runtimeException("Unknown symbolic value: ##" + o);

		return specials.valAt(o);
	}
}

public static class WrappingReader extends AFn{
	final Symbol sym;

	public WrappingReader(Symbol sym){
		this.sym = sym;
	}

	public Object invoke(Object reader, Object quote, Object opts, Object pendingForms) {
		PushbackReader r = (PushbackReader) reader;
		Object o = read(r, true, null, true, opts, ensurePending(pendingForms));
		return RT.list(sym, o);
	}

View on GitHub (pinned to f3b143341d)