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

Error when calling Enum.from_string imported from external module #20050

Closed
Ddiidev opened this issue Dec 1, 2023 · 0 comments · Fixed by #20068
Closed

Error when calling Enum.from_string imported from external module #20050

Ddiidev opened this issue Dec 1, 2023 · 0 comments · Fixed by #20068
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@Ddiidev
Copy link
Contributor

Ddiidev commented Dec 1, 2023

Describe the bug

image

Reproduction Steps

Create an enum in a module called my_module... ex:

module my_module

pub enum MyAny {
  any1
  any2
  any3
}

In another module, import and call the from_string method, e.g.:

module my_module2
import my_module { MyAny }

pub fn test() ! {
  x := MyAny.from_string('any1')
  dump(x)
}

complete code if it is more practical
test-call-method-enum.zip

Expected Behavior

The following result should return from the dump: x: Option(any1)

Current Behavior

src/my_module2/using_type_enum.v:3:8: warning: module 'my_module (src.my_module)' is imported but never used
    1 | module my_module2
    2 | 
    3 | import my_module { MyAny }
      |        ~~~~~~~~~
    4 | 
    5 | pub fn teste() ! {
V panic: sym: invalid type (typ=ast.Type(0x1000000 = 16777216) idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

v hash: 300158d
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21300: at _v_panic: Backtrace
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:48272: by v__ast__default_table_panic_handler
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:48279: by v__ast__Table_panic
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:49029: by v__ast__Table_sym
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21873: by v__checker__Checker_expr
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:17141: by v__checker__Checker_assign_stmt
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21093: by v__checker__Checker_stmt
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21661: by v__checker__Checker_stmts_ending_with_expression
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21637: by v__checker__Checker_stmts
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:28497: by v__checker__Checker_fn_decl
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:21173: by v__checker__Checker_stmt
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:19249: by v__checker__Checker_check
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:19316: by v__checker__Checker_check_files
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:48134: by v__builder__Builder_middle_stages
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:48168: by v__builder__Builder_front_and_middle_stages
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51146: by v__builder__cbuilder__gen_c
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51129: by v__builder__cbuilder__build_c
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51119: by v__builder__cbuilder__compile_c
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51016: by v__builder__Builder_rebuild
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:49662: by v__builder__compile
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51460: by main__rebuild
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:51349: by main__main
C:/Users/AndreLuiz/AppData/Local/Temp/v_0/v2.6764596675449367645.tmp.c:52121: by wmain
00c81528 : by ???
00c8168b : by ???

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 2964855.300158d

Environment details (OS name and version, etc.)

V full version: V 0.4.3 2964855.300158d
OS: windows, Microsoft Windows 11 Pro v22631 64 bits
Processor: 12 cpus, 64bit, little endian,

getwd: C:\Users\AndreLuiz\Desktop\teste
vexe: C:\v\v.exe
vexe mtime: 2023-11-30 19:24:52

vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\AndreLuiz.vmodules
VTMP: OK, value: C:\Users\AndreLuiz\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.2
Git vroot status: weekly.2023.48-20-g300158dd-dirty (5 commit(s) behind V master)
.git/config present: true

CC version: Error: 'cc' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.

thirdparty/tcc status: thirdparty-windows-amd64 a39eb79b

V full version: V 0.4.3 150f225
OS: linux, Ubuntu 22.04.3 LTS (WSL 2)
Processor: 12 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-12450H

getwd: /mnt/c/Users/AndreLuiz/Desktop/teste
vexe: /home/andre/v/v
vexe mtime: 2023-12-01 00:23:13

vroot: OK, value: /home/andre/v
VMODULES: OK, value: /root/.vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.34.1
Git vroot status: weekly.2023.38-566-g150f2259
.git/config present: true

CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@Ddiidev Ddiidev added the Bug This tag is applied to issues which reports bugs. label Dec 1, 2023
@felipensp felipensp added Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Compiler: TCC Bugs/feature requests, that are related to compiling V programs with TCC. and removed Compiler: TCC Bugs/feature requests, that are related to compiling V programs with TCC. labels Dec 1, 2023
@shove70 shove70 self-assigned this Dec 2, 2023
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
3 participants