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

Embedded struct fields are not supported by compiler #3741

Open
roman-khimov opened this issue Dec 10, 2024 · 0 comments
Open

Embedded struct fields are not supported by compiler #3741

roman-khimov opened this issue Dec 10, 2024 · 0 comments
Labels
compiler Go smart contract compiler enhancement Improving existing functionality I2 Regular impact S3 Minimally significant U4 Nothing urgent

Comments

@roman-khimov
Copy link
Member

Is your feature request related to a problem? Please describe.

I'm always frustrated when I look at the code generated for embedded fields. So I try testing it and for

--- a/pkg/compiler/struct_test.go
+++ b/pkg/compiler/struct_test.go
@@ -397,6 +397,18 @@ var structTestCases = []testCase{
                `,
                big.NewInt(42),
        },
+       {
+               "embedded struct",
+               `type S11 struct { S10; b int }
+               func F%d() int {
+                       var s S11
+                       s.a = 31
+                       s.b = 11
+                       return s.a + s.b
+               }
+               `,
+               big.NewInt(42),
+       },
        {
                "omit field names",
                `type pair struct { a, b int }

I get

--- FAIL: TestStructs (0.02s)
    --- FAIL: TestStructs/embedded_struct (0.00s)
        vm_test.go:69: 
                Error Trace:    /home/rik/dev/neo-go/pkg/compiler/vm_test.go:69
                                                        /home/rik/dev/neo-go/pkg/compiler/struct_test.go:461
                Error:          Received unexpected error:
                                at instruction 499 (SETITEM): unhandled exception: "The value -1 is out of range."
                Test:           TestStructs/embedded_struct
FAIL
FAIL    github.com/nspcc-dev/neo-go/pkg/compiler        9.481s
FAIL

Describe the solution you'd like

Add proper support for it.

@roman-khimov roman-khimov added compiler Go smart contract compiler I2 Regular impact U4 Nothing urgent enhancement Improving existing functionality S3 Minimally significant labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Go smart contract compiler enhancement Improving existing functionality I2 Regular impact S3 Minimally significant U4 Nothing urgent
Projects
None yet
Development

No branches or pull requests

1 participant