Skip to content

Commit 141925a

Browse files
rudifamvdan
authored andcommitted
internal/core/export: fix a recent nil pointer regression
Before the fix, the added test fails with a panic due a nil pointer. The fix prevents accessing the offending pointer. After the fix, the new test passes. Note that we might find a better fix down the line for the root cause; a TODO is added as a reminder. Fixes #2584. Closes #2690 as merged as of commit dec11d9. Signed-off-by: Rudi Farkas <[email protected]> Change-Id: Ic24562fee250e9efcfaaf1a0bf95a514817675a5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1172874 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent bba2263 commit 141925a

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

internal/core/export/adt.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ func (e *exporter) resolve(env *adt.Environment, r adt.Resolver) ast.Expr {
329329
// comprehensions originate from a single source and do not need to be
330330
// handled.
331331
if env != nil { // for generated stuff
332-
if v := env.Vertex; !v.IsDynamic {
332+
// TODO: note that env.Vertex should never be nil; investigate and replace the nil check below.
333+
if v := env.Vertex; v != nil && !v.IsDynamic {
333334
if v = v.Lookup(x.Label); v != nil {
334335
e.linkIdentifier(v, ident)
335336
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# issue #2584
2+
3+
-- in.cue --
4+
F1: sub1: sub2: L
5+
F2: {
6+
(string): _
7+
L
8+
}
9+
D: {}
10+
let L = D
11+
-- out/default --
12+
-- out/definition --
13+
14+
let L = D
15+
F1: {
16+
sub1: {
17+
sub2: L
18+
}
19+
}
20+
F2: {
21+
(string): _
22+
L
23+
}
24+
D: {}
25+
-- out/doc --
26+
[]
27+
[F1]
28+
[F1 sub1]
29+
[F1 sub1 sub2]
30+
[F2]
31+
[F2 _]
32+
[D]
33+
[L]
34+
-- out/value --
35+
== Simplified
36+
{
37+
let L = D
38+
F1: {
39+
sub1: {
40+
sub2: {}
41+
}
42+
}
43+
F2: {
44+
(string): _
45+
L
46+
}
47+
D: {}
48+
}
49+
== Raw
50+
{
51+
let L = D
52+
F1: {
53+
sub1: {
54+
sub2: {}
55+
}
56+
}
57+
F2: {
58+
(string): _
59+
L
60+
}
61+
D: {}
62+
}
63+
== Final
64+
{
65+
F1: {
66+
sub1: {
67+
sub2: {}
68+
}
69+
}
70+
F2: _|_ // F2: invalid non-ground value string (must be concrete string)
71+
D: {}
72+
}
73+
== All
74+
{
75+
let L = D
76+
F1: {
77+
sub1: {
78+
sub2: {}
79+
}
80+
}
81+
F2: {
82+
(string): _
83+
L
84+
}
85+
D: {}
86+
}
87+
== Eval
88+
{
89+
let L = D
90+
F1: {
91+
sub1: {
92+
sub2: {}
93+
}
94+
}
95+
F2: {
96+
(string): _
97+
L
98+
}
99+
D: {}
100+
}

0 commit comments

Comments
 (0)