summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/v2/compiler.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-08-13 16:14:26 +0200
committerGitHub <noreply@github.com>2022-08-13 16:14:26 +0200
commit6a3fc713978a0c1c9290a4afd08b47886b49b635 (patch)
treeaa62cd85cf5671646c75ee38b3fc140ef7edcea8 /vendor/github.com/d5/tengo/v2/compiler.go
parent3c4192ebf6a32e30cdd23a9644c2ceca72a006fa (diff)
downloadmatterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.gz
matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.bz2
matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.zip
Update dependencies and go1.18 (#1873)
* Update dependencies and go1.18 * Exclude unnecessary linters and update build to go1.18
Diffstat (limited to 'vendor/github.com/d5/tengo/v2/compiler.go')
-rw-r--r--vendor/github.com/d5/tengo/v2/compiler.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/github.com/d5/tengo/v2/compiler.go b/vendor/github.com/d5/tengo/v2/compiler.go
index 6591603c..0d46a4d7 100644
--- a/vendor/github.com/d5/tengo/v2/compiler.go
+++ b/vendor/github.com/d5/tengo/v2/compiler.go
@@ -692,12 +692,15 @@ func (c *Compiler) compileAssign(
return c.errorf(node, "operator ':=' not allowed with selector")
}
+ _, isFunc := rhs[0].(*parser.FuncLit)
symbol, depth, exists := c.symbolTable.Resolve(ident, false)
if op == token.Define {
if depth == 0 && exists {
return c.errorf(node, "'%s' redeclared in this block", ident)
}
- symbol = c.symbolTable.Define(ident)
+ if isFunc {
+ symbol = c.symbolTable.Define(ident)
+ }
} else {
if !exists {
return c.errorf(node, "unresolved reference '%s'", ident)
@@ -718,6 +721,10 @@ func (c *Compiler) compileAssign(
}
}
+ if op == token.Define && !isFunc {
+ symbol = c.symbolTable.Define(ident)
+ }
+
switch op {
case token.AddAssign:
c.emit(node, parser.OpBinaryOp, int(token.Add))