diff --git a/convex-core/src/main/java/convex/core/lang/Context.java b/convex-core/src/main/java/convex/core/lang/Context.java index dc65b5a6a..55d42ba3f 100644 --- a/convex-core/src/main/java/convex/core/lang/Context.java +++ b/convex-core/src/main/java/convex/core/lang/Context.java @@ -639,7 +639,7 @@ private Address getParentAddress(AccountStatus as) { */ @SuppressWarnings("unchecked") public T lookupValue(String symName) { - return (T) lookupValue(Symbol.create(symName)); + return (T) lookupValue(getAddress(),Symbol.create(symName)); } /** @@ -648,17 +648,7 @@ public T lookupValue(String symName) { * @return Value for the given symbol or null if undeclared */ public ACell lookupValue(Symbol sym) { - AHashMap env=getEnvironment(); - - // Lookup in current environment first - MapEntry me=env.getEntry(sym); - if (me!=null) { - return me.getValue(); - } - - AccountStatus as = getAliasedAccount(env); - if (as==null) return null; - return as.getEnvironment().get(sym); + return lookupValue(getAddress(),sym); } /** @@ -668,11 +658,9 @@ public ACell lookupValue(Symbol sym) { * @return Value for the given symbol or null if undeclared */ public ACell lookupValue(Address address,Symbol sym) { - if (address==null) return lookupValue(sym); - AccountStatus as=getAccountStatus(address); - if (as==null) return null; - AHashMap env=as.getEnvironment(); - return env.get(sym); + MapEntry entry=lookupDynamicEntry(address,sym); + if (entry==null) return null; + return entry.getValue(); } /** @@ -683,6 +671,7 @@ public ACell lookupValue(Address address,Symbol sym) { * @return Environment entry */ public MapEntry lookupDynamicEntry(Address address,Symbol sym) { + if (address==null) address=getAddress(); AccountStatus as=getAccountStatus(address); if (as==null) return null; return lookupDynamicEntry(as,sym);