Skip to content

Fix help message for usage of err variable in or {} block #19

@ArtemkaKun

Description

@ArtemkaKun
error(E0050): cannot pass `os.IOError` to parameter with `string` type
 --> xml.sp:7:45:48
   |
 7 |    file := os.read_file("foo.xml") or { panic(err) }
   |                                               ^^^ expected: string, got: os.IOError

note: parameter has `string` type
 --> /home/yuart/Projects/spawn/y/builtin/panic.sp:24:14:22
    |
 24 | pub fn panic(s string) -> never {
    |              ^^^^^^^^ (1) parameter declared here as `string`

help: `os.IOError` can be converted to `string` with `.str()`
 --> xml.sp:7:48:48
   |
 7 |    file := os.read_file("foo.xml") or { panic(err.str()) }
   |                                                  ++++++ add `.str()` call to convert `os.IOError` to `string`

Help proposes to use .str() but it should propose to use .msg(), since err doesn't have a method .str() implemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions