nasser / magic

Morgan And Grand Iron Clojure
http://nas.sr/magic/
365 stars 18 forks source link

Invalid bytecode with void method in or expression #157

Closed nasser closed 4 years ago

nasser commented 4 years ago
(defn invalid []
  (or (Console/WriteLine "1") false))

compiles fine, but fails verification with the following:

In method: <magic>foo$invalid__0::invoke()
Not Verifiable: Stack not empty (2) after ret at 0x004d
Error: Could not merge stacks, different sizes (3 x 2) at 0x004d
Error count: 1

expands to the following, which fails verification in the same way.

(defn invalid []
  (let [x (Console/WriteLine "1")] 
    (if x x true)))
nasser commented 4 years ago

also fails

(defn invalid []
  (let [x (Console/WriteLine "1")] 
    x))
In method: <magic>foo$invalid__4::invoke()
Not Verifiable: Stack not empty (1) after ret at 0x000e

generated bytecode

        IL_0000: ldstr "1"
        IL_0005: call void [mscorlib]System.Console::WriteLine(string)
        IL_000a: ldnull
        IL_000b: stloc.0
        IL_000c: ldloc.0
        IL_000d: ldnull
        IL_000e: ret

the ldnull IL_000d shouldnt be there