Skip to content

veb: fix generic field access from alias#25246

Merged
spytheman merged 6 commits into
vlang:masterfrom
felipensp:fix_veb_generic_cast
Sep 7, 2025
Merged

veb: fix generic field access from alias#25246
spytheman merged 6 commits into
vlang:masterfrom
felipensp:fix_veb_generic_cast

Conversation

@felipensp

Copy link
Copy Markdown
Member

Fix #25215

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-24845

Comment thread vlib/veb/controller.v Outdated
Comment thread vlib/veb/veb.v Outdated
@spytheman

Copy link
Copy Markdown
Contributor

I think, that cgen should have produced instead of this:

        controllers_sorted = array_clone_to_depth(&global_app->controllers, 0);

something like:

        controllers_sorted = array_clone_to_depth(&global_app->Controller.controllers, 0);

but it did not, because of the alias.

i.e. the proper fix would be to change cgen, to allow for an alias to a struct with embeds.

You can test with:

import veb

pub struct Context {
        veb.Context
}

pub struct App {
        veb.Middleware[Context]
        veb.Controller
        veb.StaticHandler
}

fn main() {
        port := 9008
        mut app := &App{}
        veb.run[App, Context](mut app, port)
}

(which does not use aliases), compared with the code from the issue

@felipensp felipensp marked this pull request as ready for review September 6, 2025 14:50
@spytheman spytheman merged commit 6e0fd17 into vlang:master Sep 7, 2025
74 of 83 checks passed
@felipensp felipensp deleted the fix_veb_generic_cast branch September 7, 2025 17:23
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.

[veb] C compilation error

2 participants