by alain_gilbert · 1y ago · 0 comments
But one thing that blows my mind is that if you ever encounter an "index out of range" error, the (massive) error message that you get doesn't tell you anything about where this error occurred... no line number... no nothing...
let a = [1]
print(a[1])
Is all you have to do to reproduce the error.The error looks something like that https://pastebin.com/MQV82SaR
And gives you no useful information as to how it happened or how to fix it.
compare that with Golang which tells you, it happened in main.go at line 4.
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
main.main()
/Users/username/main.go:4 +0x15
exit status 2
EDIT: with the LLVM_SYMBOLIZER_PATH set https://pastebin.com/8M9Dbrgj this doesn't provide anything useful either.Maybe the friendly default would be to have the symbolicated reports on, but perhaps this has performance impact so it’s off.
As a comment just below says, the solution is quite simple:
> ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it
This doesn't provide anything useful either.
``` swift_hello_main + 322 in swift-hello at /home/fermi/Documents/temp/swift-hello/Sources/main.swift:64:8
62│
63│ let a = [1]
64│ print(a[1])
│ ▲
65│
```>Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
?
There’s obviously a snarky comment to make here about Go developers and duplicating efforts.
Not sure how that's any better... I still have no idea that the error occurred on line 2
How would I ever know what caused the crash?
when I compile using `swiftc main.swift` and run with `./main`, the error seems even more useless.
all I get is:
Swift/ContiguousArrayBuffer.swift:600: Fatal error: Index out of range
zsh: illegal hardware instruction ./main