v icon indicating copy to clipboard operation
v copied to clipboard

builder error when accessing member on an alias on struct reference

Open LouisBrunner opened this issue 2 years ago • 0 comments

Describe the bug

Not sure if a type alias for reference on a struct should be allowed but it generates invalid C.

Expected Behavior

It builds or return a compiler error.

Current Behavior

/tmp/v_501/bug.11178753466526829536.tmp.c:2224:4: warning: expression result unused [-Wunused-value]
  (*(int*)_t1.data);
   ^~~~~~~~~~~~~~~
/tmp/v_501/bug.11178753466526829536.tmp.c:12440:21: error: member reference type 'main__RABC' (aka 'struct main__ABC *') is a pointer; did you mean to use '->'?
        println(int_str(abc.data));
                        ~~~^
                           ->

Reproduction Steps

struct ABC {
	data int
}

type RABC = &ABC

fn do(abc RABC) {
	println(abc.data)
}

fn main() {
	abc := &ABC{
		data: 5
	}
	do(abc)
}

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.3.3 9ad1c2f

Environment details (OS name and version, etc.)

V full version: V 0.3.3 ee4150f.9ad1c2f OS: macos, macOS, 13.0, 22A380 Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/louis/Dev/Projects/vgrapher vexe: /Users/louis/Dev/v/v vexe mtime: 2023-03-13 19:00:06

vroot: OK, value: /Users/louis/Dev/v VMODULES: OK, value: /Users/louis/.vmodules VTMP: OK, value: /tmp/v_501

Git version: git version 2.38.1 Git vroot status: weekly.2023.10-46-g9ad1c2f9 .git/config present: true

CC version: Apple clang version 14.0.0 (clang-1400.0.29.202) thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0

LouisBrunner avatar Mar 13 '23 19:03 LouisBrunner