We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The variable is initialized using the match construct, but an error occurs in the generated C code
const grid_size = 4 fn main() { title_parts := match grid_size { 3 {['Small', '3x3']!} 4 {['Classic', '4x4']!} 5 {['Big', '5x5']!} else {['Large', '6x6']!} } println(title_parts[0]) }
Variable title_parts should be [2]string containing ['Classic', '4x4']
title_parts
Generated C code:
Array_fixed_string_2 title_parts = ((_const_main__grid_size == (3))? ({_SLIT("Small"), _SLIT("3x3")}) : (_const_main__grid_size == (4))? ({_SLIT("Classic"), _SLIT("4x4")}) : (_const_main__grid_size == (5))? ({_SLIT("Big"), _SLIT("5x5")}) : ({_SLIT("Large"), _SLIT("6x6")}));
Error:
================== C compilation error (from tcc): ============== cc: /tmp/v_1000/VFifteen.01JJHEZ9HYVSQPM0NEGQ1VW5HM.tmp.c:13157: error: ';' expected (got "}") =================================================================
No response
0.4.9 d9f5112.801600c
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.
The text was updated successfully, but these errors were encountered:
Connected to Huly®: V_0.6-22015
Sorry, something went wrong.
In C, initializes all elements of array can only be done during its declaration. So match can't work at this case.
match
A suggest generated c code:
Array_fixed_int_2 title_parts ; Array_fixed_int_2 title_parts_3 = {2,3}; Array_fixed_int_2 title_parts_4 = {4,5}; Array_fixed_int_2 title_parts_5 = {6,7}; Array_fixed_int_2 title_parts_else = {8,9}; ( (_const_main__grid_size == (3))? memcpy(title_parts,title_parts_3,sizeof(title_parts)) : (_const_main__grid_size == (4))? memcpy(title_parts,title_parts_4,sizeof(title_parts)) : (_const_main__grid_size == (5))? memcpy(title_parts,title_parts_5,sizeof(title_parts)) : memcpy(title_parts,title_parts_else,sizeof(title_parts)) );
No branches or pull requests
Describe the bug
The variable is initialized using the match construct, but an error occurs in the generated C code
Reproduction Steps
Expected Behavior
Variable
title_parts
should be [2]string containing ['Classic', '4x4']Current Behavior
Generated C code:
Error:
Possible Solution
No response
Additional Information/Context
No response
V version
0.4.9 d9f5112.801600c
Environment details (OS name and version, etc.)
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.
The text was updated successfully, but these errors were encountered: