Skip to content
Snippets Groups Projects
Commit 46987786 authored by Florian Angerer's avatar Florian Angerer
Browse files

[GR-6503] Allow 'NULL' as enclosing env during deserialization.

PullRequest: fastr/1202
parents 995f2f6a 9f01957e
No related branches found
No related tags found
No related merge requests found
......@@ -585,8 +585,12 @@ public class RSerialize {
}
Debug.printClosure(pairList);
}
boolean restore = setupLibPath((REnvironment) tagItem);
RFunction func = PairlistDeserializer.processFunction(carItem, cdrItem, (REnvironment) tagItem, currentFunctionName, packageName);
// older versions of GnuR allowed 'NULL'
assert tagItem == RNull.instance || tagItem instanceof REnvironment;
REnvironment enclosingEnv = tagItem == RNull.instance ? REnvironment.baseEnv() : (REnvironment) tagItem;
boolean restore = setupLibPath(enclosingEnv);
RFunction func = PairlistDeserializer.processFunction(carItem, cdrItem, enclosingEnv, currentFunctionName, packageName);
if (attrItem != RNull.instance) {
setAttributes(func, attrItem);
handleFunctionSrcrefAttr(func);
......@@ -2786,6 +2790,10 @@ public class RSerialize {
* @return {@code true} if a path has been added, {@code false} otherwise.
*/
private static boolean setupLibPath(REnvironment environment) {
if (environment == REnvironment.baseEnv()) {
return false;
}
REnvironment cur = environment;
while (cur != REnvironment.emptyEnv() && !cur.isNamespaceEnv()) {
cur = cur.getParent();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment