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

vweb: use of float types as function parameters leads to C error (invalid aggregate type) #15220

Open
Apocryphon-X opened this issue Jul 25, 2022 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: vweb Bugs/feature requests, that are related to the `vweb`.

Comments

@Apocryphon-X
Copy link

Apocryphon-X commented Jul 25, 2022

V Doctor:

OS: linux, Ubuntu 20.04.4 LTS (WSL 2)
Processor: 12 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
CC version: cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

getwd: /home/apocryphon/tests/v
vmodules: /home/apocryphon/.vmodules
vroot: /home/apocryphon/packages/v
vexe: /home/apocryphon/packages/v/v
vexe mtime: 2022-07-25 17:58:05
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.0 d6de533.f1ebfb2

Git version: git version 2.25.1
Git vroot status: weekly.2022.29-64-gf1ebfb2d
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 827f7452

What did you do?

import vweb

struct App {
    vweb.Context
}

fn main() {
	vweb.run(&App{}, 8080)
}

['/sum/:num_a/:num_b']
fn (mut app App) sum(num_a f32, num_b f32) vweb.Result {
	return app.text('The sum is: ${num_a + num_b}')
}

This happens with f64 too.

What did you expect to see?

No errors.

What did you see instead?

Same error as #14428.

/tmp/v_1000/vweb_ex.11038284845365864003.tmp.c:29995: error: invalid aggregate type for register load
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang
@Apocryphon-X Apocryphon-X added the Bug This tag is applied to issues which reports bugs. label Jul 25, 2022
@Apocryphon-X
Copy link
Author

Additional output with v -cg -prod vweb_ex.v:

/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c: In functionvweb__handle_conn_T_main__App’:
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:29969:48: error: incompatible type for argument 2 ofmain__App_sum29969 |        main__App_sum(app, ((string*)args.data) [0] , ((string*)args.data) [1] );
      |                           ~~~~~~~~~~~~~~~~~~~~~^~~
      |                                                |
      |                                                string {aka struct string}
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:4658:48: note: expectedf32’ {akafloat’} but argument is of typestring’ {akastruct string’}
 4658 | vweb__Result main__App_sum(main__App* app, f32 num_a, f32 num_b);
      |                                            ~~~~^~~~~
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:29969:75: error: incompatible type for argument 3 ofmain__App_sum29969 |        main__App_sum(app, ((string*)args.data) [0] , ((string*)args.data) [1] );
      |                                                      ~~~~~~~~~~~~~~~~~~~~~^~~
      |                                                                           |
      |                                                                           string {aka struct string}
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:4658:59: note: expectedf32’ {akafloat’} but argument is of typestring’ {akastruct string’}
 4658 | vweb__Result main__App_sum(main__App* app, f32 num_a, f32 num_b);
      |                                                       ~~~~^~~~~
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:30020:54: error: incompatible type for argument 2 ofmain__App_sum30020 |       main__App_sum(app, ((string*)method_args.data) [0] , ((string*)method_args.data) [1] );
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
      |                                                      |
      |                                                      string {aka struct string}
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:4658:48: note: expectedf32’ {akafloat’} but argument is of typestring’ {akastruct string’}
 4658 | vweb__Result main__App_sum(main__App* app, f32 num_a, f32 num_b);
      |                                            ~~~~^~~~~
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:30020:88: error: incompatible type for argument 3 ofmain__App_sum30020 |       main__App_sum(app, ((string*)method_args.data) [0] , ((string*)method_args.data) [1] );
      |                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
      |                                                                                        |
      |                                                                                        string {aka struct string}
/tmp/v_1000/vweb_ex.7651033178685271020.tmp.c:4658:59: note: expectedf32’ {akafloat’} but argument is of typestring’ {akastruct string’}
 4658 | vweb__Result main__App_sum(main__App* app, f32 num_a, f32 num_b);
      |                                                       ~~~~^~~~~

@esquerbatua esquerbatua added Unit: vweb Bugs/feature requests, that are related to the `vweb`. Unit: Checker Bugs/feature requests, that are related to the type checker. and removed Unit: Checker Bugs/feature requests, that are related to the type checker. labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: vweb Bugs/feature requests, that are related to the `vweb`.
Projects
None yet
Development

No branches or pull requests

2 participants