@@ -66,7 +66,10 @@ function computeAllParentsForLabel(
6666 if ( label === end ) {
6767 return [ ] ;
6868 }
69- const parents = lattice [ label ] || [ end ] ;
69+ const parents = lattice [ label ] ;
70+ if ( ! parents ) {
71+ return [ ] ;
72+ }
7073 return parents . reduce (
7174 ( acc , parent ) => [
7275 ...acc ,
@@ -99,25 +102,18 @@ function makeLattice(latticeRelationships: LatticeRelationships): Lattice {
99102 } ;
100103
101104 // Compute all parents and children for each key
102- for ( const key in latticeRelationships )
105+ for ( const key of allKeys ) {
103106 lattice . parents [ key ] = [
104107 key ,
105108 ...computeAllParentsForLabel ( key , latticeRelationships , TOP ) ,
109+ TOP ,
106110 ] ;
107111
108- for ( const key in invertedLattice )
109112 lattice . children [ key ] = [
110113 key ,
111114 ...computeAllParentsForLabel ( key , invertedLattice , BOTTOM ) ,
115+ BOTTOM ,
112116 ] ;
113-
114- for ( const key of allKeys ) {
115- if ( ! lattice . parents [ key ] ) {
116- lattice . parents [ key ] = [ key , TOP ] ;
117- }
118- if ( ! lattice . children [ key ] ) {
119- lattice . children [ key ] = [ key , BOTTOM ] ;
120- }
121117 }
122118
123119 return lattice ;
@@ -153,12 +149,12 @@ function join(
153149
154150 return otherPrincipals . length
155151 ? ( [
156- "join" ,
157- [
158- ...otherPrincipals ,
159- ...( commonParents . length ? [ commonParents [ 0 ] ] : [ ] ) ,
160- ] ,
161- ] as PrincipalExpression )
152+ "join" ,
153+ [
154+ ...otherPrincipals ,
155+ ...( commonParents . length ? [ commonParents [ 0 ] ] : [ ] ) ,
156+ ] ,
157+ ] as PrincipalExpression )
162158 : commonParents [ 0 ] ?? TOP ;
163159}
164160
@@ -181,12 +177,12 @@ function meet(
181177
182178 return otherPrincipals . length
183179 ? ( [
184- "meet" ,
185- [
186- ...otherPrincipals ,
187- ...( commonChildren . length ? [ commonChildren [ 0 ] ] : [ ] ) ,
188- ] ,
189- ] as PrincipalExpression )
180+ "meet" ,
181+ [
182+ ...otherPrincipals ,
183+ ...( commonChildren . length ? [ commonChildren [ 0 ] ] : [ ] ) ,
184+ ] ,
185+ ] as PrincipalExpression )
190186 : commonChildren [ 0 ] ?? BOTTOM ;
191187}
192188
@@ -426,7 +422,7 @@ function findSubstitutions(
426422 ] ;
427423 newSubstitutions [ variable ] = simplifyExpression (
428424 substituteWithoutSelfReference ( [ variable , newExpression ] ) ??
429- newExpression
425+ newExpression
430426 ) ;
431427 }
432428 } ) ;
0 commit comments