ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Misleading error message related to viewpoint adaptation

Open SeanTAllen opened this issue 3 years ago • 0 comments

use "collections"

actor Main
  new create(env: Env) =>
    let a: Array[String ref] val = recover val
      let x: Array[String ref] = Array[String ref]
      x.push(String)
      x
    end

    try
      let string_from_array: String ref = a(0)
      string_from_array.append("hello")
    end

The error message is:

Error:
main.pony:12:41: right side must be a subtype of left side
      let string_from_array: String ref = a(0)
                                        ^
    Info:
    main.pony:5:18: String val is not a subtype of String ref^: val is not a subcap of ref^
        let a: Array[String ref] val = recover val
                          ^

With the error pointing at String ref and saying that String val isnt a subtype. The viewpoint adaptation that is happening isn't seen in the error message.

SeanTAllen avatar Dec 13 '21 04:12 SeanTAllen