lang: ast: Fix data race in ExprSingleton

Init the mutex everywhere, but consider calling Init instead and
plumbing though the data input field in the future.
This commit is contained in:
Samuel Gélineau
2024-01-02 22:12:55 -05:00
committed by James Shubin
parent c4a9560d53
commit 3553eb1f2a
3 changed files with 17 additions and 0 deletions

View File

@@ -169,6 +169,7 @@ func (obj *Lang) Init() error {
// TODO: change to a func when we can change hostname dynamically!
"hostname": &ast.ExprStr{V: obj.Hostname},
}
// TODO: pass `data` into ast.VarPrefixToVariablesScope ?
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
variables, err = ast.MergeExprMaps(variables, consts, addback)