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 error using unwrapped nested selector #23519

Closed
quaesitor-scientiam opened this issue Jan 19, 2025 · 3 comments · Fixed by #23521
Closed

Checker error using unwrapped nested selector #23519

quaesitor-scientiam opened this issue Jan 19, 2025 · 3 comments · Fixed by #23521

Comments

@quaesitor-scientiam
Copy link

quaesitor-scientiam commented Jan 19, 2025

V version: V 0.4.9 5d1b90b, press to see full `v doctor` output
V full version V 0.4.9 45fd7eb.5d1b90b
OS windows, Microsoft Windows 11 Pro 26100 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
Memory 77.96GB/127.92GB
V executable S:\repo\vlang\v.exe
V last modified time 2025-01-18 17:17:11
V home dir OK, value: S:\repo\vlang
VMODULES OK, value: C:\Users\john3.vmodules
VTMP OK, value: C:\Users\john3\AppData\Local\Temp\v_0
Current working dir OK, value: S:\vProjects\testit
Git version git version 2.45.1.windows.1
V git status weekly.2025.1-107-g5d1b90b3 (4 commit(s) behind V master)
.git/config present true
cc version N/A
gcc version gcc (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r2) 14.2.0
clang version (built by Brecht Sanders, r2) clang version 19.1.1
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg -cg testit.v && S:\vProjects\testit\testit.exe

module main

import os {File, open_append, Process}

type Foo = string | int | f32 | File

struct Svc {
	mut:
	process ?Process
	log ?Foo
}
fn Svc.init(log ?Foo) Svc{
	mut svc := Svc{log: log}
	if svc.log != none {
		if svc.log is string {
			dump(svc.log)
			_ := open_append(svc.log) or {panic(err)}
		}
	}
	return svc
}

struct CSvc {
	Svc
	pub mut:
	log ?Foo
}
pub fn CSvc.init(log ?Foo) CSvc {
	mut c := CSvc{log: log}
	c.Svc = Svc.init(log)
	return c
}

fn main() {
	CSvc.init(none)
}

What did you see?

testit.v:17:21: error: cannot use `Foo` as `string` in argument 1 to `os.open_append`
   15 |         if svc.log is string {
   16 |             dump(svc.log)
   17 |             _ := open_append(svc.log) or {panic(err)}
      |                              ~~~~~~~
   18 |         }
   19 |     }

What did you expect to see?

Clean compile

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.

Copy link

Connected to Huly®: V_0.6-21948

@felipensp felipensp changed the title More indirection causes CGEN build error when unwrapping Checker error using unwrapped nested selector Jan 19, 2025
@quaesitor-scientiam
Copy link
Author

Connected to #23500

@spytheman
Copy link
Member

The example from #23500 compiles with latest V.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants