-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgen: fix interface with multiple embedded fields (#19377)
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
interface NodeInterface { | ||
mut: | ||
node_type NodeType | ||
node_name string | ||
} | ||
|
||
enum NodeType { | ||
@none | ||
} | ||
|
||
struct Node { | ||
mut: | ||
// removing this field works makes `InterfaceNode(x).node_name.len` below work as expected | ||
node_type NodeType | ||
node_name string | ||
} | ||
|
||
struct Element { | ||
Node | ||
} | ||
|
||
struct HTMLElement { | ||
Element | ||
} | ||
|
||
fn test_interface_with_multi_nested_embed() { | ||
x := &HTMLElement{} | ||
struct_name_len := x.node_name.len | ||
interface_name_len := NodeInterface(x).node_name.len | ||
println('struct: ${struct_name_len}') | ||
assert struct_name_len == 0 | ||
println('interface: ${interface_name_len}') | ||
assert interface_name_len == 0 | ||
} |