| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
package cel |
| 16 |
|
| 17 |
import ( |
| 18 |
"fmt" |
| 19 |
|
| 20 |
"github.com/google/cel-go/common" |
| 21 |
"github.com/google/cel-go/common/ast" |
| 22 |
"github.com/google/cel-go/common/types" |
| 23 |
"github.com/google/cel-go/parser" |
| 24 |
|
| 25 |
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
type Macro = parser.Macro |
| 33 |
|
| 34 |
|
| 35 |
type MacroFactory = parser.MacroExpander |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
type MacroExprFactory = parser.ExprHelper |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
type MacroExpander func(eh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
type MacroExprHelper interface { |
| 58 |
|
| 59 |
Copy(*exprpb.Expr) *exprpb.Expr |
| 60 |
|
| 61 |
|
| 62 |
LiteralBool(value bool) *exprpb.Expr |
| 63 |
|
| 64 |
|
| 65 |
LiteralBytes(value []byte) *exprpb.Expr |
| 66 |
|
| 67 |
|
| 68 |
LiteralDouble(value float64) *exprpb.Expr |
| 69 |
|
| 70 |
|
| 71 |
LiteralInt(value int64) *exprpb.Expr |
| 72 |
|
| 73 |
|
| 74 |
LiteralString(value string) *exprpb.Expr |
| 75 |
|
| 76 |
|
| 77 |
LiteralUint(value uint64) *exprpb.Expr |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
NewList(elems ...*exprpb.Expr) *exprpb.Expr |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
NewMap(entries ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr |
| 86 |
|
| 87 |
|
| 88 |
NewMapEntry(key *exprpb.Expr, val *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
NewObject(typeName string, fieldInits ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr |
| 93 |
|
| 94 |
|
| 95 |
NewObjectFieldInit(field string, init *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
Fold(iterVar string, |
| 113 |
iterRange *exprpb.Expr, |
| 114 |
accuVar string, |
| 115 |
accuInit *exprpb.Expr, |
| 116 |
condition *exprpb.Expr, |
| 117 |
step *exprpb.Expr, |
| 118 |
result *exprpb.Expr) *exprpb.Expr |
| 119 |
|
| 120 |
|
| 121 |
Ident(name string) *exprpb.Expr |
| 122 |
|
| 123 |
|
| 124 |
AccuIdent() *exprpb.Expr |
| 125 |
|
| 126 |
|
| 127 |
GlobalCall(function string, args ...*exprpb.Expr) *exprpb.Expr |
| 128 |
|
| 129 |
|
| 130 |
ReceiverCall(function string, target *exprpb.Expr, args ...*exprpb.Expr) *exprpb.Expr |
| 131 |
|
| 132 |
|
| 133 |
PresenceTest(operand *exprpb.Expr, field string) *exprpb.Expr |
| 134 |
|
| 135 |
|
| 136 |
Select(operand *exprpb.Expr, field string) *exprpb.Expr |
| 137 |
|
| 138 |
|
| 139 |
OffsetLocation(exprID int64) common.Location |
| 140 |
|
| 141 |
|
| 142 |
NewError(exprID int64, message string) *Error |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
type MacroOpt = parser.MacroOpt |
| 147 |
|
| 148 |
|
| 149 |
func MacroDocs(docs ...string) MacroOpt { |
| 150 |
return parser.MacroDocs(docs...) |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
func MacroExamples(examples ...string) MacroOpt { |
| 156 |
return parser.MacroExamples(examples...) |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
func GlobalMacro(function string, argCount int, factory MacroFactory, opts ...MacroOpt) Macro { |
| 161 |
return parser.NewGlobalMacro(function, argCount, factory, opts...) |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
func ReceiverMacro(function string, argCount int, factory MacroFactory, opts ...MacroOpt) Macro { |
| 166 |
return parser.NewReceiverMacro(function, argCount, factory, opts...) |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
func GlobalVarArgMacro(function string, factory MacroFactory, opts ...MacroOpt) Macro { |
| 171 |
return parser.NewGlobalVarArgMacro(function, factory, opts...) |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
func ReceiverVarArgMacro(function string, factory MacroFactory, opts ...MacroOpt) Macro { |
| 176 |
return parser.NewReceiverVarArgMacro(function, factory, opts...) |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
func NewGlobalMacro(function string, argCount int, expander MacroExpander) Macro { |
| 183 |
expand := adaptingExpander{expander} |
| 184 |
return parser.NewGlobalMacro(function, argCount, expand.Expander) |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
func NewReceiverMacro(function string, argCount int, expander MacroExpander) Macro { |
| 191 |
expand := adaptingExpander{expander} |
| 192 |
return parser.NewReceiverMacro(function, argCount, expand.Expander) |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
func NewGlobalVarArgMacro(function string, expander MacroExpander) Macro { |
| 199 |
expand := adaptingExpander{expander} |
| 200 |
return parser.NewGlobalVarArgMacro(function, expand.Expander) |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
func NewReceiverVarArgMacro(function string, expander MacroExpander) Macro { |
| 207 |
expand := adaptingExpander{expander} |
| 208 |
return parser.NewReceiverVarArgMacro(function, expand.Expander) |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
func HasMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { |
| 213 |
ph, err := toParserHelper(meh) |
| 214 |
if err != nil { |
| 215 |
return nil, err |
| 216 |
} |
| 217 |
arg, err := adaptToExpr(args[0]) |
| 218 |
if err != nil { |
| 219 |
return nil, err |
| 220 |
} |
| 221 |
if arg.Kind() == ast.SelectKind { |
| 222 |
s := arg.AsSelect() |
| 223 |
return adaptToProto(ph.NewPresenceTest(s.Operand(), s.FieldName())) |
| 224 |
} |
| 225 |
return nil, ph.NewError(arg.ID(), "invalid argument to has() macro") |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
func ExistsMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { |
| 232 |
ph, err := toParserHelper(meh) |
| 233 |
if err != nil { |
| 234 |
return nil, err |
| 235 |
} |
| 236 |
out, err := parser.MakeExists(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) |
| 237 |
if err != nil { |
| 238 |
return nil, err |
| 239 |
} |
| 240 |
return adaptToProto(out) |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
func ExistsOneMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { |
| 247 |
ph, err := toParserHelper(meh) |
| 248 |
if err != nil { |
| 249 |
return nil, err |
| 250 |
} |
| 251 |
out, err := parser.MakeExistsOne(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) |
| 252 |
if err != nil { |
| 253 |
return nil, err |
| 254 |
} |
| 255 |
return adaptToProto(out) |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
func MapMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { |
| 269 |
ph, err := toParserHelper(meh) |
| 270 |
if err != nil { |
| 271 |
return nil, err |
| 272 |
} |
| 273 |
out, err := parser.MakeMap(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) |
| 274 |
if err != nil { |
| 275 |
return nil, err |
| 276 |
} |
| 277 |
return adaptToProto(out) |
| 278 |
} |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
func FilterMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { |
| 284 |
ph, err := toParserHelper(meh) |
| 285 |
if err != nil { |
| 286 |
return nil, err |
| 287 |
} |
| 288 |
out, err := parser.MakeFilter(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) |
| 289 |
if err != nil { |
| 290 |
return nil, err |
| 291 |
} |
| 292 |
return adaptToProto(out) |
| 293 |
} |
| 294 |
|
| 295 |
var ( |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
HasMacro = parser.HasMacro |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
AllMacro = parser.AllMacro |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
ExistsMacro = parser.ExistsMacro |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
ExistsOneMacro = parser.ExistsOneMacro |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
MapMacro = parser.MapMacro |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
MapFilterMacro = parser.MapFilterMacro |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
FilterMacro = parser.FilterMacro |
| 327 |
|
| 328 |
|
| 329 |
StandardMacros = []Macro{ |
| 330 |
HasMacro, AllMacro, ExistsMacro, ExistsOneMacro, MapMacro, MapFilterMacro, FilterMacro, |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
NoMacros = []Macro{} |
| 335 |
) |
| 336 |
|
| 337 |
type adaptingExpander struct { |
| 338 |
legacyExpander MacroExpander |
| 339 |
} |
| 340 |
|
| 341 |
func (adapt *adaptingExpander) Expander(eh parser.ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { |
| 342 |
var legacyTarget *exprpb.Expr = nil |
| 343 |
var err *Error = nil |
| 344 |
if target != nil { |
| 345 |
legacyTarget, err = adaptToProto(target) |
| 346 |
if err != nil { |
| 347 |
return nil, err |
| 348 |
} |
| 349 |
} |
| 350 |
legacyArgs := make([]*exprpb.Expr, len(args)) |
| 351 |
for i, arg := range args { |
| 352 |
legacyArgs[i], err = adaptToProto(arg) |
| 353 |
if err != nil { |
| 354 |
return nil, err |
| 355 |
} |
| 356 |
} |
| 357 |
ah := &adaptingHelper{modernHelper: eh} |
| 358 |
legacyExpr, err := adapt.legacyExpander(ah, legacyTarget, legacyArgs) |
| 359 |
if err != nil { |
| 360 |
return nil, err |
| 361 |
} |
| 362 |
ex, err := adaptToExpr(legacyExpr) |
| 363 |
if err != nil { |
| 364 |
return nil, err |
| 365 |
} |
| 366 |
return ex, nil |
| 367 |
} |
| 368 |
|
| 369 |
func wrapErr(id int64, message string, err error) *common.Error { |
| 370 |
return &common.Error{ |
| 371 |
Location: common.NoLocation, |
| 372 |
Message: fmt.Sprintf("%s: %v", message, err), |
| 373 |
ExprID: id, |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
type adaptingHelper struct { |
| 378 |
modernHelper parser.ExprHelper |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
func (ah *adaptingHelper) Copy(e *exprpb.Expr) *exprpb.Expr { |
| 383 |
return mustAdaptToProto(ah.modernHelper.Copy(mustAdaptToExpr(e))) |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
func (ah *adaptingHelper) LiteralBool(value bool) *exprpb.Expr { |
| 388 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Bool(value))) |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
func (ah *adaptingHelper) LiteralBytes(value []byte) *exprpb.Expr { |
| 393 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Bytes(value))) |
| 394 |
} |
| 395 |
|
| 396 |
|
| 397 |
func (ah *adaptingHelper) LiteralDouble(value float64) *exprpb.Expr { |
| 398 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Double(value))) |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
func (ah *adaptingHelper) LiteralInt(value int64) *exprpb.Expr { |
| 403 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Int(value))) |
| 404 |
} |
| 405 |
|
| 406 |
|
| 407 |
func (ah *adaptingHelper) LiteralString(value string) *exprpb.Expr { |
| 408 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.String(value))) |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
func (ah *adaptingHelper) LiteralUint(value uint64) *exprpb.Expr { |
| 413 |
return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Uint(value))) |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
func (ah *adaptingHelper) NewList(elems ...*exprpb.Expr) *exprpb.Expr { |
| 419 |
return mustAdaptToProto(ah.modernHelper.NewList(mustAdaptToExprs(elems)...)) |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
func (ah *adaptingHelper) NewMap(entries ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr { |
| 425 |
adaptedEntries := make([]ast.EntryExpr, len(entries)) |
| 426 |
for i, e := range entries { |
| 427 |
adaptedEntries[i] = mustAdaptToEntryExpr(e) |
| 428 |
} |
| 429 |
return mustAdaptToProto(ah.modernHelper.NewMap(adaptedEntries...)) |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
func (ah *adaptingHelper) NewMapEntry(key *exprpb.Expr, val *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry { |
| 434 |
return mustAdaptToProtoEntry( |
| 435 |
ah.modernHelper.NewMapEntry(mustAdaptToExpr(key), mustAdaptToExpr(val), optional)) |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
func (ah *adaptingHelper) NewObject(typeName string, fieldInits ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr { |
| 441 |
adaptedEntries := make([]ast.EntryExpr, len(fieldInits)) |
| 442 |
for i, e := range fieldInits { |
| 443 |
adaptedEntries[i] = mustAdaptToEntryExpr(e) |
| 444 |
} |
| 445 |
return mustAdaptToProto(ah.modernHelper.NewStruct(typeName, adaptedEntries...)) |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
func (ah *adaptingHelper) NewObjectFieldInit(field string, init *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry { |
| 450 |
return mustAdaptToProtoEntry( |
| 451 |
ah.modernHelper.NewStructField(field, mustAdaptToExpr(init), optional)) |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
func (ah *adaptingHelper) Fold(iterVar string, |
| 470 |
iterRange *exprpb.Expr, |
| 471 |
accuVar string, |
| 472 |
accuInit *exprpb.Expr, |
| 473 |
condition *exprpb.Expr, |
| 474 |
step *exprpb.Expr, |
| 475 |
result *exprpb.Expr) *exprpb.Expr { |
| 476 |
return mustAdaptToProto( |
| 477 |
ah.modernHelper.NewComprehension( |
| 478 |
mustAdaptToExpr(iterRange), |
| 479 |
iterVar, |
| 480 |
accuVar, |
| 481 |
mustAdaptToExpr(accuInit), |
| 482 |
mustAdaptToExpr(condition), |
| 483 |
mustAdaptToExpr(step), |
| 484 |
mustAdaptToExpr(result), |
| 485 |
), |
| 486 |
) |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
func (ah *adaptingHelper) Ident(name string) *exprpb.Expr { |
| 491 |
return mustAdaptToProto(ah.modernHelper.NewIdent(name)) |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
func (ah *adaptingHelper) AccuIdent() *exprpb.Expr { |
| 496 |
return mustAdaptToProto(ah.modernHelper.NewAccuIdent()) |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
func (ah *adaptingHelper) GlobalCall(function string, args ...*exprpb.Expr) *exprpb.Expr { |
| 501 |
return mustAdaptToProto(ah.modernHelper.NewCall(function, mustAdaptToExprs(args)...)) |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
func (ah *adaptingHelper) ReceiverCall(function string, target *exprpb.Expr, args ...*exprpb.Expr) *exprpb.Expr { |
| 506 |
return mustAdaptToProto( |
| 507 |
ah.modernHelper.NewMemberCall(function, mustAdaptToExpr(target), mustAdaptToExprs(args)...)) |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
func (ah *adaptingHelper) PresenceTest(operand *exprpb.Expr, field string) *exprpb.Expr { |
| 512 |
op := mustAdaptToExpr(operand) |
| 513 |
return mustAdaptToProto(ah.modernHelper.NewPresenceTest(op, field)) |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
func (ah *adaptingHelper) Select(operand *exprpb.Expr, field string) *exprpb.Expr { |
| 518 |
op := mustAdaptToExpr(operand) |
| 519 |
return mustAdaptToProto(ah.modernHelper.NewSelect(op, field)) |
| 520 |
} |
| 521 |
|
| 522 |
|
| 523 |
func (ah *adaptingHelper) OffsetLocation(exprID int64) common.Location { |
| 524 |
return ah.modernHelper.OffsetLocation(exprID) |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
func (ah *adaptingHelper) NewError(exprID int64, message string) *Error { |
| 529 |
return ah.modernHelper.NewError(exprID, message) |
| 530 |
} |
| 531 |
|
| 532 |
func mustAdaptToExprs(exprs []*exprpb.Expr) []ast.Expr { |
| 533 |
adapted := make([]ast.Expr, len(exprs)) |
| 534 |
for i, e := range exprs { |
| 535 |
adapted[i] = mustAdaptToExpr(e) |
| 536 |
} |
| 537 |
return adapted |
| 538 |
} |
| 539 |
|
| 540 |
func mustAdaptToExpr(e *exprpb.Expr) ast.Expr { |
| 541 |
out, _ := adaptToExpr(e) |
| 542 |
return out |
| 543 |
} |
| 544 |
|
| 545 |
func adaptToExpr(e *exprpb.Expr) (ast.Expr, *Error) { |
| 546 |
if e == nil { |
| 547 |
return nil, nil |
| 548 |
} |
| 549 |
out, err := ast.ProtoToExpr(e) |
| 550 |
if err != nil { |
| 551 |
return nil, wrapErr(e.GetId(), "proto conversion failure", err) |
| 552 |
} |
| 553 |
return out, nil |
| 554 |
} |
| 555 |
|
| 556 |
func mustAdaptToEntryExpr(e *exprpb.Expr_CreateStruct_Entry) ast.EntryExpr { |
| 557 |
out, _ := ast.ProtoToEntryExpr(e) |
| 558 |
return out |
| 559 |
} |
| 560 |
|
| 561 |
func mustAdaptToProto(e ast.Expr) *exprpb.Expr { |
| 562 |
out, _ := adaptToProto(e) |
| 563 |
return out |
| 564 |
} |
| 565 |
|
| 566 |
func adaptToProto(e ast.Expr) (*exprpb.Expr, *Error) { |
| 567 |
if e == nil { |
| 568 |
return nil, nil |
| 569 |
} |
| 570 |
out, err := ast.ExprToProto(e) |
| 571 |
if err != nil { |
| 572 |
return nil, wrapErr(e.ID(), "expr conversion failure", err) |
| 573 |
} |
| 574 |
return out, nil |
| 575 |
} |
| 576 |
|
| 577 |
func mustAdaptToProtoEntry(e ast.EntryExpr) *exprpb.Expr_CreateStruct_Entry { |
| 578 |
out, _ := ast.EntryExprToProto(e) |
| 579 |
return out |
| 580 |
} |
| 581 |
|
| 582 |
func toParserHelper(meh MacroExprHelper) (parser.ExprHelper, *Error) { |
| 583 |
ah, ok := meh.(*adaptingHelper) |
| 584 |
if !ok { |
| 585 |
return nil, common.NewError(0, |
| 586 |
fmt.Sprintf("unsupported macro helper: %v (%T)", meh, meh), |
| 587 |
common.NoLocation) |
| 588 |
} |
| 589 |
return ah.modernHelper, nil |
| 590 |
} |