Skip to content

cgen error: could not find method, for compiling a veb program with an app alias, with defined index route on the unaliased App type #25253

Description

@spytheman
V version: V 0.4.11 930c84d, press to see full `v doctor` output
V full version V 0.4.11 1820a55.930c84d
OS linux, Ubuntu 20.04.6 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
Memory 0.98GB/15.05GB
V executable /home/delian/v/v
V last modified time 2025-09-07 06:07:01
V home dir OK, value: /home/delian/v
VMODULES OK, value: /home/delian/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/delian/v
env VFLAGS "-no-parallel"
Git version git version 2.50.0
V git status weekly.2025.36-27-g930c84db-dirty
.git/config present true
cc version cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
gcc version gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
clang version N/A
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.31-0ubuntu9.18) 2.31

What did you do?
./v -g -o vdbg cmd/v && ./vdbg x.v && x

import veb

pub struct Context {
	veb.Context
}

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

pub fn (mut app App) index(mut ctx Context) veb.Result {
	return ctx.text('Hello V!')
}

type AliasApp = App
type AliasContext = Context

mut app := &AliasApp{}
veb.run_at[AliasApp, AliasContext](mut app,
	port: 12343
	family: .ip
)

What did you see?

vlib/veb/veb.v:746:13: cgen error: could not find method `index` on compile-time resolution
  744 | 
  745 |                             // println('m1')
  746 |                             app.$method(mut user_context, args)
      |                                  ~~~~~~
  747 |                         } else {
  748 |                             // println('m2')

What did you expect to see?

A compiled program, and the veb server should handle / and /index routes by responding with Hello V!.

This was found, while reviewing #25246 (which needed a simpler cgen change).

I expect that I would be able to define the route method on both the unaliased type, and on the aliased type too. If there are 2 definitions, the method route definition on the aliased type should be chosen over the unaliased method route. There should be no compile time errors.

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.ComptimeFeatures processed during compile time, like $if, $for, $env etcGenerics[T]Bugs/feature requests, that are related to the V generics.Unit: cgenBugs/feature requests, that are related to the default C generating backend.Unit: vebBugs/feature requests, that are related to the `veb`, V's official web framework.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions