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

checker,cgen: checker checks wrapped generic type, cgen uses incorrect type #20664

Open
MCausc78 opened this issue Jan 26, 2024 · 0 comments
Open
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@MCausc78
Copy link
Contributor

MCausc78 commented Jan 26, 2024

Describe the bug

<title>

Also cgen error if i will use fn, like:

	f[Foo](fn (foo Foo) int {
		return foo.v
	})

Reproduction Steps

struct Default[T] {
	v T
}

fn default[T]() T {
	return Default[T]{}.v
}

fn f[T](g fn (x T) int) {
	assert g(Default[T]{}) == 42
}

struct Foo {
	v int = 42
}

fn main() {
	f[Foo](|foo| foo.v)
}

Expected Behavior

Successful compile

Current Behavior

PS D:\Games\Proekti\V\interactions> v run test2.v
test2.v:18:19: error: `T` has no property `v`
   16 | 
   17 | fn main() {
   18 |     f[Foo](|foo| foo.v)
      |                      ^
   19 | }
test2.v:18:9: error: `foo.v` used as value
   16 |
   17 | fn main() {
   18 |     f[Foo](|foo| foo.v)
      |            ~~~~~~~~~~~
   19 | }
test2.v:18:9: error: cannot use `fn (T) int` as `fn (Foo) int` in argument 1 to `f`
   16 |
   17 | fn main() {
   18 |     f[Foo](|foo| foo.v)
      |            ~~~~~~~~~~~
   19 | }

If I use fn

PS D:\Games\Proekti\V\interactions> v run test2.v
==================
C:/Users/mclr/AppData/Local/Temp/v_0/test2.01HN37J6S2MRNQ2AFTC712ESXK.tmp.c:6875: warning: implicit declaration of function 'tcc_backtrace'
C:/Users/mclr/AppData/Local/Temp/v_0/test2.01HN37J6S2MRNQ2AFTC712ESXK.tmp.c:13018: error: cannot convert 'struct main__Default_T_main__Foo' to 'struct main__Foo'
...
==================
(Use `v -cg` to print the entire error message)

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

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 2a68e2b

Environment details (OS name and version, etc.)

V full version: V 0.4.4 57a33c3.2a68e2b
OS: windows, Microsoft Windows 11 Pro v22000 64-bit
Processor: 12 cpus, 64bit, little endian, 

getwd: D:\Games\Proekti\V\interactions
vexe: D:\Games\Proekti\V\v\v.exe
vexe mtime: 2024-01-26 15:50:25

vroot: OK, value: D:\Games\Proekti\V\v
VMODULES: OK, value: C:\Users\mclr\.vmodules
VTMP: OK, value: C:\Users\mclr\AppData\Local\Temp\v_0

Git version: git version 2.37.0.windows.1
Git vroot status: weekly.2024.03-79-g2a68e2b7
.git/config present: true

CC version:
thirdparty/tcc status: thirdparty-windows-amd64 a39eb79b

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.

@MCausc78 MCausc78 added the Bug This tag is applied to issues which reports bugs. label Jan 26, 2024
@felipensp felipensp added Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Jan 27, 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. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

No branches or pull requests

2 participants