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

CGEN error with map having optional sumtype #23650

Closed
quaesitor-scientiam opened this issue Feb 3, 2025 · 6 comments · Fixed by #23652
Closed

CGEN error with map having optional sumtype #23650

quaesitor-scientiam opened this issue Feb 3, 2025 · 6 comments · Fixed by #23652
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@quaesitor-scientiam
Copy link
Contributor

quaesitor-scientiam commented Feb 3, 2025

V version: V 0.4.9 5c04f32, press to see full `v doctor` output
V full version V 0.4.9 45fd7eb.5c04f32
OS windows, Microsoft Windows 11 Pro 26100 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
Memory 72.43GB/127.92GB
V executable S:\repo\vlang\v.exe
V last modified time 2025-02-03 15:51:54
V home dir OK, value: S:\repo\vlang
VMODULES OK, value: C:\Users\john3.vmodules
VTMP OK, value: S:\temp\v_0
Current working dir OK, value: S:\vProjects\vSelenium
Git version git version 2.45.1.windows.1
V git status weekly.2025.04-90-g5c04f32f
.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 main.v && S:\vProjects\vSelenium\main.exe
See attached file main.v

What did you see?

webdriver/remote/connection_manager.v:3:8: warning: module 'pool (sync.pool)' is imported but never used
    1 | module remote
    2 | 
    3 | import sync.pool {PoolProcessor, PoolProcessorConfig, new_pool_processor}
      |        ~~~~~~~~~
    4 | import net.http
    5 |
webdriver/remote/remote_connection.v:8:8: warning: module 'pool (sync.pool)' is imported but never used
    6 | import encoding.base64
    7 | import maps {merge, merge_in_place}
    8 | import sync.pool
      |        ~~~~~~~~~
    9 | 
   10 | type Any = ?int | ?string
webdriver/common/selenium_manager.v:140:3: warning: unused variable: `arch`
  138 |         s.machine = un.machine
  139 |         s.user_os = os.user_os()
  140 |         arch := if s.user_os in ['linux', 'freebsd', 'openbsd'] { s.machine } else { 'any' }
      |         ~~~~
  141 |         if s.user_os in ['freebsd', 'openbsd'] {
  142 |             log.warn('Selenium Manager binary may not be compatible with ${s.user_os}; verify settings')
webdriver/remote/remote_connection.v:67:2: warning: unused variable: `path_string`
   65 |     }
   66 | 
   67 |     path_string := command_info[1]
      |     ~~~~~~~~~~~
   68 |     
   69 | }
webdriver/chromium/web_driver.v:39:2: warning: unused variable: `executor`
   37 |     drv.service.start()
   38 | 
   39 |     executor := ChromiumRemoteConnection.init(
      |     ~~~~~~~~
   40 |         drv.service.service_url, browser_name, vendor_prefix, kalive, drv.options.ignore_local_proxy, none)
   41 |
S:/temp/v_0/main.01JK6SPDP1YMPET0YXV6N26HGE.tmp.c:846: warning: WINVER redefined

S:/temp/v_0/main.01JK6SPDP1YMPET0YXV6N26HGE.tmp.c:1248: warning: InterlockedIncrement64 redefined

In file included from S:/temp/v_0/main.01JK6SPDP1YMPET0YXV6N26HGE.tmp.c:1628:

s:/repo/vlang/thirdparty/tcc/include/winapi/synchapi.h:13: warning: CreateEvent redefined

In file included from S:/temp/v_0/main.01JK6SPDP1YMPET0YXV6N26HGE.tmp.c:1628:

s:/repo/vlang/thirdparty/tcc/include/winapi/synchapi.h:117: warning: OpenEvent redefined

In file included from S:/temp/v_0/main.01JK6SPDP1YMPET0YXV6N26HGE.tmp.c:1628:

s:/repo/vlang/thirdparty/tcc/include/winap
> [!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.
@Eliyaan
Copy link
Contributor

Eliyaan commented Feb 3, 2025

is it normal that I dont see the file supposedly attached?

Copy link

Connected to Huly®: V_0.6-22071

@quaesitor-scientiam
Copy link
Contributor Author

Working on smaller example

@quaesitor-scientiam
Copy link
Contributor Author

quaesitor-scientiam commented Feb 4, 2025

main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.zip

Smaller example compiles fine not sure how to create a smaller one that gets the build error.

Here is the C code generating the error

webdriver__remote__ConnectionManager webdriver__remote__RemoteConnection_get_connection_manager(webdriver__remote__RemoteConnection* r) {
	Map_string__option_webdriver__remote__Any pool_manager_args = new_map(sizeof(string), sizeof(_option_webdriver__remote__Any), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string)
	;
	if ((r->client_config).state != 2) {
		map_set(&pool_manager_args, &(string[]){_SLIT("timeout")}, &(_option_webdriver__remote__Any[]) { (*(webdriver__remote__ClientConfig*)(r->client_config.data)).timeout });
		if (((*(webdriver__remote__ClientConfig*)(r->client_config.data)).init_args_for_pool_manager).state != 2) {
			maps__merge_in_place_T_string__option_webdriver__remote__Any(&pool_manager_args, (*(Map_string_webdriver__remote__Any*)((*(webdriver__remote__ClientConfig*)(r->client_config.data)).init_args_for_pool_manager.data)));
		}
		if ((*(webdriver__remote__ClientConfig*)(r->client_config.data)).ignore_certificates) {
			_option_webdriver__remote__Any _t1;
			_option_ok(&(webdriver__remote__Any[]) { _SLIT("CERT_NONE") }, (_option*)(&_t1), sizeof(webdriver__remote__Any));
			map_set(&pool_manager_args, &(string[]){_SLIT("cert_reqs")}, &(_option_webdriver__remote__Any[]) { _t1 });
		} else if (((*(webdriver__remote__ClientConfig*)(r->client_config.data)).ca_certs).state != 2) {
			_option_webdriver__remote__Any _t2;
			_option_ok(&(webdriver__remote__Any[]) { _SLIT("CERT_REQUIRED") }, (_option*)(&_t2), sizeof(webdriver__remote__Any));
			map_set(&pool_manager_args, &(string[]){_SLIT("cert_reqs")}, &(_option_webdriver__remote__Any[]) { _t2 });
			_option_webdriver__remote__Any _t3;
			_option_ok(&(webdriver__remote__Any[]) { (*(string*)((*(webdriver__remote__ClientConfig*)(r->client_config.data)).ca_certs.data)) }, (_option*)(&_t3), sizeof(webdriver__remote__Any));
			map_set(&pool_manager_args, &(string[]){_SLIT("ca_certs")}, &(_option_webdriver__remote__Any[]) { _t3 });
		}
	}
	if ((r->proxy_url).state != 2) {
		if (string_starts_with(string_to_lower((*(string*)(r->proxy_url.data))), _SLIT("sock"))) {
			return ((webdriver__remote__ConnectionManager){.url = (*(string*)(r->proxy_url.data)),.args = pool_manager_args,});
		}
	}
	return ((webdriver__remote__ConnectionManager){.url = (string){.str=(byteptr)"", .is_lit=1},.args = pool_manager_args,});
}

@quaesitor-scientiam
Copy link
Contributor Author

   40 |
main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.c
S:\temp\v_0\main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.c(34260): error C2440: 'initializing': cannot convert from '_option_int' to 'byte'
S:\temp\v_0\main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.c(34266): error C2440: 'initializing': cannot convert from 'string' to '_option_int *'
S:\temp\v_0\main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.c(34270): error C2440: 'initializing': cannot convert from 'string' to '_option_int *'
S:\temp\v_0\main.01JK78A4RYHEH8QSB91F8JYPHN.tmp.c(34273): error C2440: 'initializing': cannot convert from 'string' to '_option_int *'

@felipensp
Copy link
Member

type Any = ?int | ?string

struct TestConfig {
	timeout ?int
}

struct Test {
	client_config TestConfig
}

fn main() {
	mut r := Test{
		client_config: TestConfig{
			timeout: 0
		}
	}
	mut pool_manager_args := map[string]?Any{}
	pool_manager_args['timeout'] = r.client_config.timeout
}

@felipensp felipensp self-assigned this Feb 4, 2025
@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. labels Feb 4, 2025
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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants