vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.67k stars 2.15k forks source link

seems error happend when trying to access a folder under Documents macos #21533

Open foxjazz opened 3 months ago

foxjazz commented 3 months ago

V doctor:

V full version: V 0.4.5 9f2cb8c
OS: macos, macOS, 14.4.1, 23E224
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/foxjazz/Code/v-file-scanner/src
vexe: /Users/foxjazz/Code/v/v
vexe mtime: 2024-05-19 09:02:22

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

Git version: git version 2.43.0
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false

CC version: Apple clang version 12.0.5 (clang-1205.0.22.11)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

What did you do? v -g -o vdbg cmd/v && vdbg file.v

    println('Hello World!')
    folder := "/Users/foxjazz/Documents/EVE/logs/ChatLogs"
    entries := os.ls(folder) or { [] }
    println("entries")
    println(entries.count)```

**What did you expect to see?**

entries

**What did you see instead?**

builder error: file.v doesn't exist


> [!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.
foxjazz commented 3 months ago
println('Hello World!')
folder := "/Users/foxjazz/Documents/EVE/logs/ChatLogs"
entries := os.ls(folder) or { [] }
println("entries")
println(entries.count)
juan-db commented 3 months ago

V can't determine the type of the array in the or block. I am assuming you're not importing os so it doesn't know the return type of os.ls.

If you import os or change line 3 to entries := os.ls(folder) or { []string{} }, you will get more helpful errors.

Obviously the panic should still be addressed, just sharing my findings so far.