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#L407v.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 ?
For now, hil always generate string, with
hil.Parse
andhil.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 likeCall(__builtin_BoolToString, Call(__builtin_IntCompare, Literal(TypeInt, 12), Literal(TypeInt, 2), Literal(TypeInt, 1)))
for${2 > 1}
orCall(__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 ?