mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
veb: fix generic field access from alias (fix #25215) (#25246)
Some checks are pending
Graphics CI / gg-regressions (push) Waiting to run
vlib modules CI / build-module-docs (push) Waiting to run
native backend CI / native-backend-ubuntu (push) Waiting to run
native backend CI / native-backend-windows (push) Waiting to run
Shy and PV CI / v-compiles-puzzle-vibes (push) Waiting to run
Sanitized CI / sanitize-undefined-clang (push) Waiting to run
Sanitized CI / sanitize-undefined-gcc (push) Waiting to run
Sanitized CI / tests-sanitize-address-clang (push) Waiting to run
Sanitized CI / sanitize-address-msvc (push) Waiting to run
Sanitized CI / sanitize-address-gcc (push) Waiting to run
Sanitized CI / sanitize-memory-clang (push) Waiting to run
sdl CI / v-compiles-sdl-examples (push) Waiting to run
Time CI / time-linux (push) Waiting to run
Time CI / time-macos (push) Waiting to run
Time CI / time-windows (push) Waiting to run
toml CI / toml-module-pass-external-test-suites (push) Waiting to run
Tools CI / tools-linux (clang) (push) Waiting to run
Tools CI / tools-linux (gcc) (push) Waiting to run
Tools CI / tools-linux (tcc) (push) Waiting to run
Tools CI / tools-macos (clang) (push) Waiting to run
Tools CI / tools-windows (gcc) (push) Waiting to run
Tools CI / tools-windows (msvc) (push) Waiting to run
Tools CI / tools-windows (tcc) (push) Waiting to run
Tools CI / tools-docker-ubuntu-musl (push) Waiting to run
wasm backend CI / wasm-backend (ubuntu-22.04) (push) Waiting to run
vab CI / vab-compiles-v-examples (push) Waiting to run
vab CI / v-compiles-os-android (push) Waiting to run
wasm backend CI / wasm-backend (windows-2022) (push) Waiting to run
Some checks are pending
Graphics CI / gg-regressions (push) Waiting to run
vlib modules CI / build-module-docs (push) Waiting to run
native backend CI / native-backend-ubuntu (push) Waiting to run
native backend CI / native-backend-windows (push) Waiting to run
Shy and PV CI / v-compiles-puzzle-vibes (push) Waiting to run
Sanitized CI / sanitize-undefined-clang (push) Waiting to run
Sanitized CI / sanitize-undefined-gcc (push) Waiting to run
Sanitized CI / tests-sanitize-address-clang (push) Waiting to run
Sanitized CI / sanitize-address-msvc (push) Waiting to run
Sanitized CI / sanitize-address-gcc (push) Waiting to run
Sanitized CI / sanitize-memory-clang (push) Waiting to run
sdl CI / v-compiles-sdl-examples (push) Waiting to run
Time CI / time-linux (push) Waiting to run
Time CI / time-macos (push) Waiting to run
Time CI / time-windows (push) Waiting to run
toml CI / toml-module-pass-external-test-suites (push) Waiting to run
Tools CI / tools-linux (clang) (push) Waiting to run
Tools CI / tools-linux (gcc) (push) Waiting to run
Tools CI / tools-linux (tcc) (push) Waiting to run
Tools CI / tools-macos (clang) (push) Waiting to run
Tools CI / tools-windows (gcc) (push) Waiting to run
Tools CI / tools-windows (msvc) (push) Waiting to run
Tools CI / tools-windows (tcc) (push) Waiting to run
Tools CI / tools-docker-ubuntu-musl (push) Waiting to run
wasm backend CI / wasm-backend (ubuntu-22.04) (push) Waiting to run
vab CI / vab-compiles-v-examples (push) Waiting to run
vab CI / v-compiles-os-android (push) Waiting to run
wasm backend CI / wasm-backend (windows-2022) (push) Waiting to run
This commit is contained in:
parent
7cba3a249b
commit
6e0fd17a72
2 changed files with 54 additions and 1 deletions
|
@ -4479,7 +4479,7 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
|
||||||
}
|
}
|
||||||
// struct embedding
|
// struct embedding
|
||||||
mut has_embed := false
|
mut has_embed := false
|
||||||
if sym.info in [ast.Struct, ast.Aggregate] {
|
if sym.info in [ast.Alias, ast.Struct, ast.Aggregate] {
|
||||||
if node.generic_from_embed_types.len > 0 && sym.info is ast.Struct {
|
if node.generic_from_embed_types.len > 0 && sym.info is ast.Struct {
|
||||||
if sym.info.embeds.len > 0 {
|
if sym.info.embeds.len > 0 {
|
||||||
mut is_find := false
|
mut is_find := false
|
||||||
|
|
53
vlib/veb/tests/veb_aliased_app_and_context_test.v
Normal file
53
vlib/veb/tests/veb_aliased_app_and_context_test.v
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
import os
|
||||||
|
import veb
|
||||||
|
import time
|
||||||
|
import net.http
|
||||||
|
|
||||||
|
const app_port = 29123
|
||||||
|
const exit_after = 10 * time.second
|
||||||
|
|
||||||
|
pub struct Context {
|
||||||
|
veb.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct App {
|
||||||
|
veb.Middleware[Context]
|
||||||
|
veb.Controller
|
||||||
|
veb.StaticHandler
|
||||||
|
started chan bool
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut app App) before_accept_loop() {
|
||||||
|
app.started <- true
|
||||||
|
}
|
||||||
|
|
||||||
|
type AliasApp = App
|
||||||
|
type AliasContext = Context
|
||||||
|
|
||||||
|
fn testsuite_begin() {
|
||||||
|
os.chdir(os.dir(@FILE))!
|
||||||
|
spawn fn () {
|
||||||
|
time.sleep(exit_after)
|
||||||
|
assert true == false, 'timeout reached!'
|
||||||
|
exit(1)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_aliased_app_compiles_and_starts() {
|
||||||
|
mut app := &AliasApp{}
|
||||||
|
spawn veb.run_at[AliasApp, AliasContext](mut app,
|
||||||
|
port: app_port
|
||||||
|
timeout_in_seconds: 2
|
||||||
|
family: .ip
|
||||||
|
)
|
||||||
|
eprintln('waiting for app to start ...')
|
||||||
|
_ := <-app.started
|
||||||
|
eprintln('>>> app was started')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_static_root() {
|
||||||
|
x := http.get('http://127.0.0.1:${app_port}/')!
|
||||||
|
eprintln('>>>> http request was sent and received')
|
||||||
|
assert x.status() == .not_found
|
||||||
|
assert x.body == '404 Not Found'
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue