internal/rosa/azalea: pass through source ident
All checks were successful
Test / ShareFS (push) Successful in 41s
Test / Sandbox (push) Successful in 48s
Test / Hakurei (push) Successful in 51s
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (race detector) (push) Successful in 2m27s
Test / Hakurei (race detector) (push) Successful in 3m29s
Test / Flake checks (push) Successful in 1m23s
All checks were successful
Test / ShareFS (push) Successful in 41s
Test / Sandbox (push) Successful in 48s
Test / Hakurei (push) Successful in 51s
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (race detector) (push) Successful in 2m27s
Test / Hakurei (race detector) (push) Successful in 3m29s
Test / Flake checks (push) Successful in 1m23s
For source handle special case. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -142,10 +142,13 @@ var (
|
||||
IdentInputs = unique.Make(Ident("inputs"))
|
||||
// IdentRuntime has the same semantics as [IdentInputs].
|
||||
IdentRuntime = unique.Make(Ident("runtime"))
|
||||
// IdentSource is a special argument in a package declaration where an
|
||||
// assignment of a [Val] with a single [Ident] passes through the evaluator.
|
||||
IdentSource = unique.Make(Ident("source"))
|
||||
|
||||
// ErrInvalidInputs is panicked for an [IdentInputs] argument to [PF]
|
||||
// sharing its value or set for R.
|
||||
ErrInvalidInputs = errors.New("inputs must not be common or bound to scope")
|
||||
// ErrInvalidSpecial is panicked for a special [PF] argument sharing its
|
||||
// value or set for R.
|
||||
ErrInvalidSpecial = errors.New("special must not be common or bound to scope")
|
||||
)
|
||||
|
||||
// evaluateAny implements [Evaluate].
|
||||
@@ -291,7 +294,7 @@ func evaluateAny(d PF, s []Frame, expr, rp any) bool {
|
||||
} {
|
||||
if slices.Contains(names, special) {
|
||||
if len(names) != 1 || len(arg.V) != 1 || arg.R {
|
||||
panic(ErrInvalidInputs)
|
||||
panic(ErrInvalidSpecial)
|
||||
}
|
||||
farg.K = names[0]
|
||||
if err := storeE(&farg.V, arg.V[0]); err != nil {
|
||||
@@ -301,6 +304,20 @@ func evaluateAny(d PF, s []Frame, expr, rp any) bool {
|
||||
continue args
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(names, IdentSource) {
|
||||
if len(names) != 1 || len(arg.V) != 1 || arg.R {
|
||||
panic(ErrInvalidSpecial)
|
||||
}
|
||||
if _, ok = arg.V[0].(Ident); ok {
|
||||
farg.K = names[0]
|
||||
if err := storeE(&farg.V, arg.V[0]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fargs = append(fargs, farg)
|
||||
continue args
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !evaluateAny(d, s, arg.V, &farg.V) {
|
||||
|
||||
Reference in New Issue
Block a user