Skip to content

Commit c65cf42

Browse files
committed
Issue yuin#225: wrong compile time constant folding
1 parent 7b93173 commit c65cf42

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

compile.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,7 @@ func constFold(exp ast.Expr) ast.Expr { // {{{
11071107
panic(fmt.Sprintf("unknown binop: %v", expr.Operator))
11081108
}
11091109
} else {
1110-
retexpr := *expr
1111-
retexpr.Lhs = constFold(expr.Lhs)
1112-
retexpr.Rhs = constFold(expr.Rhs)
1113-
return &retexpr
1110+
return expr
11141111
}
11151112
case *ast.UnaryMinusOpExpr:
11161113
expr.Expr = constFold(expr.Expr)

go.mod

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module github.com/yuin/gopher-lua
22

3-
require github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
3+
require (
4+
github.com/chzyer/logex v1.1.10 // indirect
5+
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
6+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
7+
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952 // indirect
8+
)

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
2+
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
13
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
24
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
6+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
7+
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952 h1:FDfvYgoVsA7TTZSbgiqjAbfPbK47CNHdWl3h/PJtii0=
8+
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

0 commit comments

Comments
 (0)