compiler: do not emit code for unnamed unused variables

If variable is unnamed and does not contain function call then it's
treated as unused and code generation may be omitted for it
initialization/declaration.
This commit is contained in:
Anna Shaleva 2022-08-19 14:54:42 +03:00
parent 1dcbdb011a
commit 91b36657d6
8 changed files with 151 additions and 18 deletions

View file

@ -100,7 +100,7 @@ func TestInitWithNoGlobals(t *testing.T) {
func Main() int {
return 42
}`
v, s := vmAndCompileInterop(t, src)
v, s, _ := vmAndCompileInterop(t, src)
require.NoError(t, v.Run())
assertResult(t, v, big.NewInt(42))
require.True(t, len(s.events) == 1)