Skip to content

Commit 8ac1161

Browse files
authored
Fix empty namespace check on kw in codegen (#118)
Missed a callsite after changing return type of keyword Namespace() method. Signed-off-by: James Hamlin <[email protected]>
1 parent 12b5650 commit 8ac1161

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/runtime/codegen.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ func (g *Generator) generateValue(value any) string {
461461
case *lang.MultiFn:
462462
return g.generateMultiFn(v)
463463
case lang.Keyword:
464-
if ns := v.Namespace(); ns != "" {
464+
if ns := v.Namespace(); ns != nil {
465465
return g.allocKWVar(fmt.Sprintf("%s/%s", ns, v.Name()))
466466
} else {
467467
return g.allocKWVar(v.Name())
@@ -1213,11 +1213,11 @@ func (g *Generator) generateCase(node *ast.Node) string {
12131213
// if a test matches, we evaluate the corresponding body and assign to resultVar
12141214
// Generate code based on test type
12151215
testType := caseNode.TestType.(lang.Keyword)
1216-
1216+
12171217
// Calculate the lookup key based on test type
12181218
lookupVar := g.allocateTempVar()
12191219
g.writef("var %s int64\n", lookupVar)
1220-
1220+
12211221
switch testType {
12221222
case lang.KWInt:
12231223
// For integers, convert directly to int64 and apply shift/mask
@@ -1234,7 +1234,7 @@ func (g *Generator) generateCase(node *ast.Node) string {
12341234
g.writef("%s = int64(uint32(%s >> %d) & uint32(%d))\n",
12351235
lookupVar, lookupVar, caseNode.Shift, caseNode.Mask)
12361236
}
1237-
1237+
12381238
case lang.KWHashIdentity:
12391239
// Use identity hash
12401240
if caseNode.Mask == 0 {
@@ -1243,7 +1243,7 @@ func (g *Generator) generateCase(node *ast.Node) string {
12431243
g.writef("%s = int64(uint32(lang.IdentityHash(%s) >> %d) & uint32(%d))\n",
12441244
lookupVar, testExpr, caseNode.Shift, caseNode.Mask)
12451245
}
1246-
1246+
12471247
case lang.KWHashEquiv:
12481248
// Use hash
12491249
if caseNode.Mask == 0 {
@@ -1253,19 +1253,19 @@ func (g *Generator) generateCase(node *ast.Node) string {
12531253
lookupVar, testExpr, caseNode.Shift, caseNode.Mask)
12541254
}
12551255
}
1256-
1256+
12571257
// Generate switch statement for the entries
12581258
first := true
12591259
for i, entry := range caseNode.Entries {
12601260
g.writef("// case entry %d (key=%d, collision=%v)\n", i, entry.Key, entry.HasCollision)
1261-
1261+
12621262
if first {
12631263
g.writef("if %s == %d {\n", lookupVar, entry.Key)
12641264
first = false
12651265
} else {
12661266
g.writef("} else if %s == %d {\n", lookupVar, entry.Key)
12671267
}
1268-
1268+
12691269
if entry.HasCollision {
12701270
// For collision cases, evaluate the condp expression
12711271
condpExpr := g.generateASTNode(entry.ResultExpr)

0 commit comments

Comments
 (0)