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
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:
@@ -115,7 +115,7 @@ func (e TypeError) Is(err error) bool {
|
||||
}
|
||||
|
||||
// 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()
|
||||
v := reflect.ValueOf(r)
|
||||
pt, vt := pv.Type(), v.Type()
|
||||
@@ -226,6 +226,9 @@ func evaluateAny(d PF, s []Frame, expr, rp any) bool {
|
||||
case "false":
|
||||
store(rp, false)
|
||||
return true
|
||||
case "nil":
|
||||
reflect.ValueOf(rp).Elem().SetZero()
|
||||
return true
|
||||
default:
|
||||
return evaluateAny(d, s, v, rp)
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ func TestEvaluate(t *testing.T) {
|
||||
Err: UndefinedError("f"),
|
||||
}},
|
||||
|
||||
{"error wrap deep", `f { v = nil; }`, makeStackCheck(func(
|
||||
{"error wrap deep", `f { v = nonexistent; }`, makeStackCheck(func(
|
||||
FArgs,
|
||||
) (any, error) {
|
||||
panic("unreachable")
|
||||
}), "", EvaluationError{
|
||||
Expr: Ident("nil"),
|
||||
Err: UndefinedError("nil"),
|
||||
Expr: Ident("nonexistent"),
|
||||
Err: UndefinedError("nonexistent"),
|
||||
}},
|
||||
|
||||
{"common inputs", `package name { inputs, v = []; }`, nil, "", EvaluationError{
|
||||
|
||||
Reference in New Issue
Block a user