aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/azalea/evaluate.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-19 18:05:39 +0900
committerOphestra <cat@gensokyo.uk>2026-05-19 18:10:11 +0900
commit3010a209b52c3103a1f2dea5442aa1e7428855b4 (patch)
treea05e7cb23b6982b6843f748fc82e591262a56326 /internal/rosa/azalea/evaluate.go
parente65a3b435ca4a000a41ddbba68a07bf7c3036f06 (diff)
internal/rosa/azalea: pass through source ident
For source handle special case. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/azalea/evaluate.go')
-rw-r--r--internal/rosa/azalea/evaluate.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/internal/rosa/azalea/evaluate.go b/internal/rosa/azalea/evaluate.go
index 063471e1..617a1618 100644
--- a/internal/rosa/azalea/evaluate.go
+++ b/internal/rosa/azalea/evaluate.go
@@ -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) {