ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

"can't use an undefined variable in an expression" error message oddity around "always true" conditionals that defined the variable

Open pmetras opened this issue 1 year ago • 3 comments

This seems related to issue #2784.

Following code (Playground)

actor Main
  var _x: U8
  new create(env: Env) =>
    while true do
      _x = 5
      break
    end
    let y = _x + 2
    env.out.print("y = " + y .string())

does not compile with error

0.52.2-f7d01e80 [release]
Compiled with: LLVM 14.0.3 -- Clang-13.0.1-x86_64
Defaults: pic=true
Error:
main.pony:8:13: can't use an undefined variable in an expression
    let y = _x + 2
            ^

pmetras avatar Dec 12 '22 02:12 pmetras