v icon indicating copy to clipboard operation
v copied to clipboard

Compiler build error: cannot convert 'struct main__Object' to 'struct main__Object *

Open pd-giz-dave opened this issue 7 months ago • 3 comments

Describe the bug

Attempt to compile this:

module main
import json
@[heap]
pub struct Logger {
}
struct SaveParams[T] {
	object &T
}
pub fn (mut l Logger) save[T](p SaveParams[T]) {
	json.encode(p.object)
}
struct Object {
	s1 string = 'a string'
}
fn main() {
	mut logger := &Logger{}
	logger.save(object: &Object{}) //to_save)
	println('\\o//')
}

It results in:

/home/dave/v/v /home/dave/precious/fellsafe/v/compiler_bugs -color -o /home/dave/precious/fellsafe/v/bin/main
==================
/tmp/v_1000/main.01J2C3CGZWAPXQBC8PQ9T3F0B1.tmp.c:2241: error: cannot convert 'struct main__Object' to 'struct main__Object *'
...
==================
(Use `v -cg` to print the entire error message)
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Reproduction Steps

Attempt to compile the above code

Expected Behavior

It should compile

Current Behavior

Get build error: cannot convert 'struct main__Object' to 'struct main__Object *'

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.6 66ea826

Environment details (OS name and version, etc.)

dave@dave-mini-pc~/.../fellsafe/v >>> v doctor
V full version: V 0.4.6 294f7e4.66ea826
OS: linux, "EndeavourOS Linux"
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 5800H with Radeon Graphics

getwd: /home/dave/precious/fellsafe/v
vexe: /home/dave/v/v
vexe mtime: 2024-07-08 15:23:28

vroot: OK, value: /home/dave/v
VMODULES: OK, value: /home/dave/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.45.2
Git vroot status: weekly.2024.27-32-g66ea8260
.git/config present: true

CC version: cc (GCC) 14.1.1 20240522
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

[!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.

pd-giz-dave avatar Jul 09 '24 16:07 pd-giz-dave