-
Notifications
You must be signed in to change notification settings - Fork 346
Description
What version of CUE are you using (cue version)?
$ cue version v0.15.3
Does this issue reproduce with the latest stable release?
Yes
What did you do?
Here's as minimal a repro as I could make: https://github.com/mezuzza/cue-panic
All you need to do is clone that repo, make sure cue is installed, and run cue eval ./infra/gcp -e out.
I have a map where I define environments:
#Environments: {
dev: _ // This should be {} but it's not used right now.
}Later, I reference it through this:
infra: {
dev: this={
(google.#Project & {in: {
// Change this to this.#envName and no panic.
name: "mez-\(this.#env)"
orgId: "${(org.ref).id}"
}}).out
}
}
Note that #env here references the value in the #Environments struct while this.#envName references the key. It's definitely incorrect, but the compiler shouldn't panic, it should tell me what's wrong.
EDIT: I was able to simplify this further and the envName thing seem to be a red herring...though it does solve the problem in my previous version for some reason. At this point, i'ts 96 lines of code (imports and package statements included).
What did you expect to see?
A normal error saying what the issue is with my code
What did you see instead?
✓ ~/code/cue-panic (master ✔) » cue eval ./infra/gcp -e out
panic: unreachable
goroutine 1 [running]:
cuelang.org/go/internal/core/export.relPathLength(...)
cuelang.org/go/internal/core/export/self.go:379
cuelang.org/go/internal/core/export.(*pivotter).makeAlternativeReference(0xc000397500, 0xc000096c90, {0x12dd1d0?, 0xc0004a20a0?})
cuelang.org/go/internal/core/export/self.go:292 +0x6ae
cuelang.org/go/internal/core/export.(*pivotter).refExpr(0xc000397500, {0x12dd1d0, 0xc0004a20a0})
cuelang.org/go/internal/core/export/self.go:421 +0x8b
cuelang.org/go/internal/core/export.(*exporter).resolve(0xc0003980b0, 0xc0000b5a00, {0x12dd1d0, 0xc0004a20a0})
cuelang.org/go/internal/core/export/adt.go:401 +0x5f
cuelang.org/go/internal/core/export.(*exporter).adt(0xc0003980b0, 0xc0000b5a00, {0x79a80df9f840?, 0xc0004a20a0})
cuelang.org/go/internal/core/export/adt.go:138 +0x693
cuelang.org/go/internal/core/export.(*exporter).expr(0xc0003980b0, 0xc0000b5a00?, {0x79a80df9f840?, 0xc0004a20a0})
cuelang.org/go/internal/core/export/expr.go:101 +0x415
cuelang.org/go/internal/core/export.(*conjuncts).addExpr(0xc000518eb0, 0xc0000b5a00, 0x0, {0x79a80df9f840, 0xc0004a20a0}, 0x1)
cuelang.org/go/internal/core/export/expr.go:470 +0x3f0
cuelang.org/go/internal/core/export.(*conjuncts).addExpr(0xc000518eb0, 0xc0000b59c0, 0xc0001300a0, {0x12dea90, 0xc00047d230}, 0x0)
cuelang.org/go/internal/core/export/expr.go:399 +0x12e5
cuelang.org/go/internal/core/export.(*conjuncts).addExpr(0xc000518eb0, 0xc0000b59c0, 0xc0001300a0, {0x12de9b0, 0xc00047d2c0}, 0x0)
cuelang.org/go/internal/core/export/expr.go:454 +0xb1f
cuelang.org/go/internal/core/export.(*exporter).mergeValues(0xc0003980b0, 0x4e6840?, 0xc0001300a0, {0xc000037bd0, 0x1, 0xc000519948?}, {0xc000037e00, 0x1, 0x1})
cuelang.org/go/internal/core/export/expr.go:155 +0x70d
cuelang.org/go/internal/core/export.(*exporter).mergeValues(0xc0003980b0, 0x519b18?, 0xc00043fd60, {0xc000037ae0, 0x1, 0xc000519ac8?}, {0xc00049a870, 0x1, 0x1})
cuelang.org/go/internal/core/export/expr.go:259 +0x19a5
cuelang.org/go/internal/core/export.(*exporter).expr(0xc0003980b0, 0x480518?, {0x12dea20?, 0xc00043fd60})
cuelang.org/go/internal/core/export/expr.go:91 +0x15b
cuelang.org/go/internal/core/export.(*pivotter).addExternal(0xc000397500, 0xc0001233b0)
cuelang.org/go/internal/core/export/self.go:435 +0x4b
cuelang.org/go/internal/core/export.(*exporter).completePivot(0xc0003980b0?, 0xc00038f030)
cuelang.org/go/internal/core/export/self.go:63 +0x6b
cuelang.org/go/internal/core/export.(*exporter).finalize(0xc0003980b0, 0x12e58e0?, {0x12e6998?, 0xc000123c70?})
cuelang.org/go/internal/core/export/export.go:434 +0x3e
cuelang.org/go/internal/core/export.(*Profile).Vertex(0xc000302240?, {0x12e57f0?, 0xc000302240?}, {0x0?, 0xc0002c1510?}, 0xc0004b40a0)
cuelang.org/go/internal/core/export/export.go:296 +0xa7
cuelang.org/go/cue.Value.Syntax({0xc000302240?, 0xc0004b40a0?, 0x0?}, {0xc00041e0d0, 0x5, 0x12e6c26?})
cuelang.org/go/cue/types.go:944 +0x245
cuelang.org/go/cmd/cue/cmd.runEval(0xc0002d8810, {0xc0002d9890, 0x1, 0x3})
cuelang.org/go/cmd/cue/cmd/eval.go:171 +0xb25
cuelang.org/go/cmd/cue/cmd.newEvalCmd.mkRunE.func1(0xc0001d5000?, {0xc0002d9890, 0x1, 0x3})
cuelang.org/go/cmd/cue/cmd/root.go:154 +0x2d5
github.com/spf13/cobra.(*Command).execute(0xc0002ea008, {0xc0002d9830, 0x3, 0x3})
github.com/spf13/[email protected]/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001cf208)
github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1071
github.com/spf13/cobra.(*Command).ExecuteContext(...)
github.com/spf13/[email protected]/command.go:1064
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0xc0002d8810, {0x12de658?, 0xc0002d9770?})
cuelang.org/go/cmd/cue/cmd/root.go:406 +0x5c
cuelang.org/go/cmd/cue/cmd.Main()
cuelang.org/go/cmd/cue/cmd/root.go:305 +0x138
main.main()
cuelang.org/go/cmd/cue/main.go:24 +0x13