diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-02-21 21:09:58 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-02-21 21:09:58 +0000 |
commit | 9671d467aca8b7c9cae17e40ba3ff81a611fbe22 (patch) | |
tree | 9e4ee8c5c27f5c27b09c930525e64cbe782e3067 /src | |
parent | 1c9de854a30e116e502c2d0bebaadce8f80219fb (diff) |
allow use of not-yet-existing names qualified with current namespace when internNew
Diffstat (limited to 'src')
-rw-r--r-- | src/jvm/clojure/lang/Compiler.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index c4d6ea47..376fa4b9 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -312,7 +312,7 @@ static class DefExpr implements Expr{ throw new Exception("Can't create defs outside of current ns"); } IPersistentMap mm = sym.meta(); - mm = (IPersistentMap) RT.assoc(mm, RT.LINE_KEY, LINE.get()).assoc(RT.FILE_KEY,SOURCE.get()); + mm = (IPersistentMap) RT.assoc(mm, RT.LINE_KEY, LINE.get()).assoc(RT.FILE_KEY, SOURCE.get()); Expr meta = analyze(context == C.EVAL ? context : C.EXPRESSION, mm); return new DefExpr(v, analyze(context == C.EVAL ? context : C.EXPRESSION, RT.third(form), v.sym.name), meta, RT.count(form) == 3); @@ -3299,13 +3299,17 @@ static public Object resolveIn(Namespace n, Symbol sym) throws Exception{ static Var lookupVar(Symbol sym, boolean internNew) throws Exception{ Var var = null; - //note - ns-qualified vars must already exist + //note - ns-qualified vars in other namespaces must already exist if(sym.ns != null) { Namespace ns = Namespace.find(Symbol.create(sym.ns)); if(ns == null) throw new Exception("No such namespace: " + sym.ns); - var = ns.findInternedVar(Symbol.create(sym.name)); + Symbol name = Symbol.create(sym.name); + if(internNew && ns == currentNS()) + var = currentNS().intern(name); + else + var = ns.findInternedVar(name); } else { |