From 04ff2a8c5cde860bb7e3ca040de3630ae2a2252f Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 4 Aug 2025 22:06:02 -0400 Subject: [PATCH] lang: ast: Turn this speculation flag into a const Makes it easier to find when debugging. --- lang/ast/structs.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lang/ast/structs.go b/lang/ast/structs.go index f130fc11..314a41dd 100644 --- a/lang/ast/structs.go +++ b/lang/ast/structs.go @@ -127,6 +127,13 @@ const ( // XXX: not implemented AllowUserDefinedPolyFunc = false + // AllowSpeculation will simplify the function graph shape considerably + // at the expense of a generally small amount of overhead during compile + // time. It's mostly recommended that this is set to true, but it is + // sometimes made false when debugging scenarios containing the extended + // graph shape using CallFunc and other similar function call nodes. + AllowSpeculation = true + // RequireStrictModulePath can be set to true if you wish to ignore any // of the metadata parent path searching. By default that is allowed, // unless it is disabled per module with ParentPathBlock. This option is @@ -10958,7 +10965,7 @@ func (obj *ExprCall) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, //exprFunc, ok := obj.expr.(*ExprFunc) // XXX: Does this need to be .Pure for it to be allowed? //canSpeculate := !ok || exprFunc.function == nil || (exprFunc.function.Info().Fast && exprFunc.function.Info().Spec) - canSpeculate := true // XXX: use the magic Info fields? + canSpeculate := AllowSpeculation // XXX: use the magic Info fields? exprValue, err := obj.expr.Value() exprFuncValue, ok := exprValue.(*full.FuncValue) if err == nil && ok && canSpeculate {