Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: fix auto str for interface struct member which implements str method #19970

Merged
merged 5 commits into from
Nov 23, 2023

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Nov 23, 2023

Fix #18547

🤖[deprecated] Generated by Copilot at e2df780

This pull request implements and tests the feature request #10464, which enables automatic str methods for interfaces. It modifies the vlib/v/gen/c/str.v and vlib/v/gen/c/auto_str_methods.v files to generate correct C code for calling str methods on interface values, and adds a new test file vlib/v/tests/interface_auto_str_test.v to verify the expected behavior.

🤖[deprecated] Generated by Copilot at e2df780

  • Add a special case for interfaces with str methods in vlib/v/gen/c/auto_str_methods.v (link)
  • Handle DumpExpr for interfaces and other types with custom str methods in vlib/v/gen/c/str.v (link, link)
  • Add a test file vlib/v/tests/interface_auto_str_test.v to check the expected output of the str and dump methods for interfaces and structs (link)

@felipensp felipensp marked this pull request as ready for review November 23, 2023 13:48
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 9ca4c22 into vlang:master Nov 23, 2023
55 checks passed
@felipensp felipensp deleted the fix_interface_auto_str branch November 23, 2023 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using an interface with a custom str method in a struct produces a C error
2 participants