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

v panic when embedding struct alias into another struct #23347

Closed
islonely opened this issue Jan 2, 2025 · 0 comments · Fixed by #23353
Closed

v panic when embedding struct alias into another struct #23347

islonely opened this issue Jan 2, 2025 · 0 comments · Fixed by #23353
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

@islonely
Copy link
Contributor

islonely commented Jan 2, 2025

V doctor:

V full version: V 0.4.9 4225a34.b79257b
OS: macos, macOS, 15.1.1, 24B91
Processor: 8 cpus, 64bit, little endian, Apple M3

getwd: /Users/adamoates/Documents/v_tests
vexe: /Users/adamoates/v/v
vexe mtime: 2025-01-02 15:24:10

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

Git version: git version 2.39.5 (Apple Git-154)
Git vroot status: weekly.2024.53-14-gb79257b7 (1 commit(s) behind V master)
.git/config present: true

CC version: Apple clang version 16.0.0 (clang-1600.0.26.4)
emcc version: N/A
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

What did you do?
./v -g -o vdbg cmd/v && ./vdbg /Users/adamoates/Documents/v_tests/test.v && /Users/adamoates/Documents/v_tests/test

struct Foo1 {}

type Foo2 = Foo1

struct Bar {
	Foo2
}

fn main() {
	println(Bar{})
}

What did you see?

================ V panic ================
   module: builtin
 function: __as_cast()
  message: as cast: cannot cast `v.ast.Alias` to `v.ast.Struct`
     file: /Users/adamoates/v/vlib/builtin/builtin.v:40
   v hash: b79257b
=========================================
0   vdbg                                0x000000010221563c __as_cast + 588
1   vdbg                                0x0000000102493298 v__gen__c__Gen_struct_init + 7460
2   vdbg                                0x00000001023ebda8 v__gen__c__Gen_expr + 11644
3   vdbg                                0x00000001023ede74 v__gen__c__Gen_expr_with_cast + 5608
4   vdbg                                0x000000010240381c v__gen__c__Gen_gen_expr_to_string + 4340
5   vdbg                                0x00000001024b9aa4 v__gen__c__Gen_fn_call + 10020
6   vdbg                                0x0000000102473d14 v__gen__c__Gen_call_expr + 5328
7   vdbg                                0x00000001023e9894 v__gen__c__Gen_expr + 2152
8   vdbg                                0x00000001024548f0 v__gen__c__Gen_stmt + 1356
9   vdbg                                0x0000000102453fcc v__gen__c__Gen_stmts_with_tmp_var + 3616
10  vdbg                                0x00000001024052d4 v__gen__c__Gen_stmts + 88
11  vdbg                                0x00000001024b155c v__gen__c__Gen_gen_fn_decl + 16168
12  vdbg                                0x0000000102456aa0 v__gen__c__Gen_fn_decl + 2504
13  vdbg                                0x000000010245447c v__gen__c__Gen_stmt + 216
14  vdbg                                0x0000000102453fcc v__gen__c__Gen_stmts_with_tmp_var + 3616
15  vdbg                                0x00000001024052d4 v__gen__c__Gen_stmts + 88
16  vdbg                                0x000000010243c2a4 v__gen__c__Gen_gen_file + 384
17  vdbg                                0x000000010243bda0 v__gen__c__cgen_process_one_file_cb + 5484
18  vdbg                                0x00000001022633fc sync__pool__process_in_thread + 152
19  vdbg                                0x00000001021e8b64 sync__pool__process_in_thread_thread_wrapper + 44
20  libsystem_pthread.dylib             0x0000000194c7f2e4 _pthread_start + 136
21  libsystem_pthread.dylib             0x0000000194c7a0fc thread_start + 8

What did you expect to see?

Expected Foo1 to be embedded into Bar with the field name as Foo2

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.

Huly®: V_0.6-21778

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

2 participants