Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 7d314ea

Browse files
author
sam boyer
authored
Merge pull request #95 from grafana/fix-structs-with-only-one-ref
Fix structs with only one reference
2 parents 7257adf + 63024ba commit 7d314ea

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

generate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func TestGenerateWithImports(t *testing.T) {
4646
ToDo: map[string]string{
4747
"imports/oneref_verbose": "Figure out how to disambiguate struct literals from the struct-with-braces-and-one-element case",
4848
"imports/struct_shorthand": "Shorthand struct notation is currently unsupported, needs fixing",
49-
"imports/single_embed": "Single-item struct embeds should be treated as just another interface to compose, but get confused with references - #60",
5049
"imports/inline_comments": "Inline comments do not appear be retrievable from cue.Value.Doc()",
5150
"imports/nulltype": "null types are not handled correctly",
5251
},

generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ func valError(v cue.Value, format string, args ...interface{}) error {
12891289
func refAsInterface(v cue.Value) (ts.Expr, error) {
12901290
// Bail out right away if the value isn't a reference
12911291
op, dvals := v.Expr()
1292-
if !isReference(v) || op != cue.SelectorOp {
1292+
if !isReference(v) && op != cue.SelectorOp {
12931293
return nil, fmt.Errorf("not a reference")
12941294
}
12951295

testdata/imports/single_embed.txtar

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ export interface Attrib {
3737
ImportedInner: {
3838
nestedval: string;
3939
};
40-
importedNoAttribField: string;
40+
importedAttribField: string;
4141
}
4242

4343
export interface Wrapped extends Attrib {}
44-
export interface dep.Wrapped extends dep.Attrib {}
44+
45+
export interface DepWrapped extends dep.Attrib {}

0 commit comments

Comments
 (0)