Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hack - allow merging empty containers

commit 4865e86871f5ef274b9e56fd79d9fdd35627fc8d 1 parent 616e8ac
@sorear authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 lib/Kernel.cs
View
19 lib/Kernel.cs
@@ -782,6 +782,21 @@ public sealed class RuntimeUnit : IFreeze {
return Kernel.NewTypedScalar(null);
}
+ static bool IsEmptyAggr(Variable v) {
+ if (!v.islist) return false;
+ P6any p = v.Fetch();
+ if (p.mo == Kernel.ArrayMO) {
+ return ((VarDeque)p.GetSlot("items")).Count() == 0 &&
+ ((VarDeque)p.GetSlot("rest")).Count() == 0;
+ }
+ else if (p.mo == Kernel.HashMO) {
+ return Kernel.UnboxAny<VarHash>(p).Count == 0;
+ }
+ else {
+ return false;
+ }
+ }
+
public static string NsMerge(string who, string name,
ref StashEnt nse, StashEnt ose) {
@@ -790,11 +805,11 @@ public sealed class RuntimeUnit : IFreeze {
bool nseod = nseo.IsDefined();
bool oseod = oseo.IsDefined();
// lowest priority are empty common symbols
- if (nse.v.rw && !nseod) {
+ if (nse.v.rw && !nseod || IsEmptyAggr(nse.v)) {
nse = ose;
return null;
}
- if (ose.v.rw && !oseod) {
+ if (ose.v.rw && !oseod || IsEmptyAggr(ose.v)) {
return null;
}
Please sign in to comment.
Something went wrong with that request. Please try again.