Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

super[<expr>] fails when expr is not a variable reference #679

Open
mkmik opened this issue Apr 1, 2023 · 0 comments
Open

super[<expr>] fails when expr is not a variable reference #679

mkmik opened this issue Apr 1, 2023 · 0 comments
Labels

Comments

@mkmik
Copy link

mkmik commented Apr 1, 2023

Jsonnet version:

$ jsonnet --version
Jsonnet commandline interpreter (Go implementation) v0.19.1

super[variable] works:

$ jsonnet -e '{a:1} + {local c=$.c, s: super[c], c: "a"}' 
{
   "a": 1,
   "c": "a",
   "s": 1
}

super[$.field] crashes:

$ jsonnet -e '{a:1} + {s: super[$.c], c: "a"}' 
INTERNAL ERROR: (CRASH) Unexpected node &ast.Dollar{NodeBase:ast.NodeBase{Fodder:ast.Fodder{}, Ctx:(ast.Context)(nil), FreeVars:ast.Identifiers{}, LocRange:ast.LocationRange{File:(*ast.Source)(0x14000091440), FileName:"", Begin:ast.Location{Line:1, Column:19}, End:ast.Location{Line:1, Column:20}}}}
goroutine 1 [running]:
runtime/debug.Stack()
        /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/debug/stack.go:24 +0x64
github.com/google/go-jsonnet.(*VM).evaluateSnippet.func1()
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:214 +0x3c
panic({0x100fa5760, 0x1400008e7f0})
        /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/panic.go:884 +0x204
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x100fd3500?, 0x140000bb5e0}, 0x1, 0x100eb8dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:155 +0xaa0
github.com/google/go-jsonnet/internal/program.visitNext({0x100fd3500, 0x140000bb5e0}, 0x0?, 0x0?, 0x140001f56b8)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x100fd36f8?, 0x1400009a8f0}, 0x1, 0x100eb8dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:105 +0x718
github.com/google/go-jsonnet/internal/program.visitNext({0x100fd36f8, 0x1400009a8f0}, 0x0?, 0x0?, 0x140001f6008)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x100fd3a10?, 0x140000fe000}, 0x1, 0x0?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:103 +0x3f4
github.com/google/go-jsonnet/internal/program.visitNext({0x100fd3a10, 0x140000fe000}, 0x3a?, 0x1?, 0x140001f6958)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x100fd34b8?, 0x140000fe180}, 0x0, 0x100eb8dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:127 +0xfc8
github.com/google/go-jsonnet/internal/program.visitNext({0x100fd34b8, 0x140000fe180}, 0x12?, 0x140000a8090?, 0x140001f72a8)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x100fd3428?, 0x140000e8420}, 0x0, 0x4?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:70 +0x3a8
github.com/google/go-jsonnet/internal/program.analyze({0x100fd3428, 0x140000e8420})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:165 +0x128
github.com/google/go-jsonnet/internal/program.SnippetToAST({0x100f30c0f?, 0x16f02afb3?}, {0x0?, 0x100f2b4c4?}, {0x16f02afb3?, 0x14000090150?})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/program.go:19 +0x5c
github.com/google/go-jsonnet.(*VM).evaluateSnippet(0x140001f7f00, {0x100f30c0f?, 0x0?}, {0x0?, 0x140000dbd38?}, {0x16f02afb3?, 0x28?}, 0x0)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:217 +0x84
github.com/google/go-jsonnet.(*VM).EvaluateAnonymousSnippet(0x140001f7f00, {0x100f30c0f?, 0x14000070da8?}, {0x16f02afb3?, 0x140000dbf00?})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:371 +0x3c
main.main()
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/cmd/jsonnet/cmd.go:450 +0x66c

Please report a bug here: https://github.com/google/go-jsonnet/issues

super[self.field] crashes:

$ jsonnet -e '{a:1} + {s: super[self.c], c: "a"}'
INTERNAL ERROR: (CRASH) Unexpected node <nil>
goroutine 1 [running]:
runtime/debug.Stack()
        /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/debug/stack.go:24 +0x64
github.com/google/go-jsonnet.(*VM).evaluateSnippet.func1()
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:214 +0x3c
panic({0x104e45760, 0x140001107e0})
        /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/panic.go:884 +0x204
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x0?, 0x0}, 0x1, 0x104d58dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:155 +0xaa0
github.com/google/go-jsonnet/internal/program.visitNext({0x0, 0x0}, 0x0?, 0x0?, 0x140002756b8)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x104e736f8?, 0x1400011c8f0}, 0x1, 0x104d58dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:106 +0x734
github.com/google/go-jsonnet/internal/program.visitNext({0x104e736f8, 0x1400011c8f0}, 0x0?, 0x0?, 0x14000276008)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x104e73a10?, 0x14000180000}, 0x1, 0x0?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:103 +0x3f4
github.com/google/go-jsonnet/internal/program.visitNext({0x104e73a10, 0x14000180000}, 0x3a?, 0x1?, 0x14000276958)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x104e734b8?, 0x14000180180}, 0x0, 0x104d58dc8?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:127 +0xfc8
github.com/google/go-jsonnet/internal/program.visitNext({0x104e734b8, 0x14000180180}, 0x12?, 0x1400012a090?, 0x140002772a8)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:35 +0x38
github.com/google/go-jsonnet/internal/program.analyzeVisit({0x104e73428?, 0x14000168420}, 0x0, 0x4?)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:70 +0x3a8
github.com/google/go-jsonnet/internal/program.analyze({0x104e73428, 0x14000168420})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/static_analyzer.go:165 +0x128
github.com/google/go-jsonnet/internal/program.SnippetToAST({0x104dd0c0f?, 0x16b18afb3?}, {0x0?, 0x104dcb4c4?}, {0x16b18afb3?, 0x14000112150?})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/internal/program/program.go:19 +0x5c
github.com/google/go-jsonnet.(*VM).evaluateSnippet(0x14000277f00, {0x104dd0c0f?, 0x0?}, {0x0?, 0x1400015bd38?}, {0x16b18afb3?, 0x28?}, 0x0)
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:217 +0x84
github.com/google/go-jsonnet.(*VM).EvaluateAnonymousSnippet(0x14000277f00, {0x104dd0c0f?, 0x14000070da8?}, {0x16b18afb3?, 0x1400015bf00?})
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/vm.go:371 +0x3c
main.main()
        /private/tmp/go-jsonnet-20221028-94917-fg07tm/go-jsonnet-0.19.1/cmd/jsonnet/cmd.go:450 +0x66c

Please report a bug here: https://github.com/google/go-jsonnet/issues
@sbarzowski sbarzowski added the bug label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants