internal/rosa/azalea: store the zero value for nil
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m55s
Test / Hakurei (push) Successful in 4m35s
Test / Sandbox (race detector) (push) Successful in 5m44s
Test / Hakurei (race detector) (push) Successful in 7m0s
Test / ShareFS (push) Successful in 7m19s
Test / Flake checks (push) Successful in 1m8s

This is not final, but the behaviour is acceptable for now.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
cat
2026-08-10 18:14:12 +09:00
parent f1ffb180bc
commit c8c524eac6
2 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -115,7 +115,7 @@ func (e TypeError) Is(err error) bool {
} }
// storeE is a convenience function to set the value of a result pointer. // storeE is a convenience function to set the value of a result pointer.
func storeE(rp any, r any) error { func storeE(rp, r any) error {
pv := reflect.ValueOf(rp).Elem() pv := reflect.ValueOf(rp).Elem()
v := reflect.ValueOf(r) v := reflect.ValueOf(r)
pt, vt := pv.Type(), v.Type() pt, vt := pv.Type(), v.Type()
@@ -226,6 +226,9 @@ func evaluateAny(d PF, s []Frame, expr, rp any) bool {
case "false": case "false":
store(rp, false) store(rp, false)
return true return true
case "nil":
reflect.ValueOf(rp).Elem().SetZero()
return true
default: default:
return evaluateAny(d, s, v, rp) return evaluateAny(d, s, v, rp)
} }
+3 -3
View File
@@ -100,13 +100,13 @@ func TestEvaluate(t *testing.T) {
Err: UndefinedError("f"), Err: UndefinedError("f"),
}}, }},
{"error wrap deep", `f { v = nil; }`, makeStackCheck(func( {"error wrap deep", `f { v = nonexistent; }`, makeStackCheck(func(
FArgs, FArgs,
) (any, error) { ) (any, error) {
panic("unreachable") panic("unreachable")
}), "", EvaluationError{ }), "", EvaluationError{
Expr: Ident("nil"), Expr: Ident("nonexistent"),
Err: UndefinedError("nil"), Err: UndefinedError("nonexistent"),
}}, }},
{"common inputs", `package name { inputs, v = []; }`, nil, "", EvaluationError{ {"common inputs", `package name { inputs, v = []; }`, nil, "", EvaluationError{