hashicorp / hashicorp/hil

Using hil as a predicate DSL

Open
#56 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
405
Forks
32
Avg merge
23h 7m
Merged PRs (30d)
1

Description

For now, *hil* always generate string, with `hil.Parse` and `hil.Eval`.

*hil* uses types, but some magic implicit conversion to string happens.

If you spy here : https://github.com/hashicorp/hil/blob/master/eval.go#L407 `v.Exprs` contains a chain of calls (and their arguments), something like `Call(__builtin_BoolToString, Call(__builtin_IntCompare, Literal(TypeInt, 12), Literal(TypeInt, 2), Literal(TypeInt, 1)))` for `${2 > 1}` or `Call(__builtin_IntToString, Literal(TypeInt, 42))` for `${ 42 }`. The string conversion is in the executable AST tree.

I read all the steps, from scanner to parser to AST to eval, puts a lots of ugly `fmt.Println`, but I can't find where the implicit conversion to string happens.

Can you add some options for using *hil* as a simple script language that return typed result ?

Contributor guide

Open the contributing guide

Research direction

Start with eval.go around the referenced v.Exprs code, then trace the scanner, parser, AST, and eval stages through hil.Parse and hil.Eval. Clarify the design for typed results and options for predicate use, and define the expected behavior before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.