Skip to content

Commit cbb27e8

Browse files
Chris Manghaneianlancetaylor
authored andcommitted
compiler: Make empty interface types for vars during parse time.
When making the type for a variable with an empty interface type, the parser makes an interface type with a NULL method set and relies on later passes to correct this. For sink variables, which are ignored in later passes, the interface method table is never finalized and a compile time assertion is issued. Instead, the initial type generated by the parser should be the empty interface type. Fixes golang/go#11579. Change-Id: I479559f270ddf88afc7a33103c0f56afda195d94 Reviewed-on: https://go-review.googlesource.com/12049 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent b4a932b commit cbb27e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go/parse.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,11 @@ Parse::interface_type(bool record)
12251225
methods = NULL;
12261226
}
12271227

1228-
Interface_type* ret = Type::make_interface_type(methods, location);
1228+
Interface_type* ret;
1229+
if (methods == NULL)
1230+
ret = Type::make_empty_interface_type(location);
1231+
else
1232+
ret = Type::make_interface_type(methods, location);
12291233
if (record)
12301234
this->gogo_->record_interface_type(ret);
12311235
return ret;

0 commit comments

Comments
 (0)