Casting interface as itself generates invalid C code #17056
Labels
Bug
This tag is applied to issues which reports bugs.
Unit: cgen
Bugs/feature requests, that are related to the default C generating backend.
Describe the bug
Smartcasting an interface to itself creates invalid C-code and generates a casting function (in C) which unnecessarily duplicates the interface struct.
Expected Behavior
Smartcasting an interface to its self should have no effect!
Current Behavior
Causes C compiler error.
Reproduction Steps
The following code produces the problem:
C compiler error:
Possible Solution
No response
Additional Information/Context
In addition, the following unnecessary code is generated in C by V:
Issues with above generated code:
I_main__Foo_is_I_main__Foo(main__Foo x)
is alwaysTrue
, isn't it? Or canx._typ
be 0?I_main__Foo_as_I_main__Foo(main__Foo x)
is unnecessary, I think?I_main__Foo_as_I_main__Foo(main__Foo x)
callsI_main__Bar_to_Interface_main__Foo()
which makes a NEWmain.Foo
and copies values in to it!V version
V 0.4.0 207203f
Environment details (OS name and version, etc.)
macos
The text was updated successfully, but these errors were encountered: