PLTools / Lama

Teaching language LaMa for a compiler course
GNU General Public License v3.0
67 stars 28 forks source link

Pattern matching failed #15

Closed evjava closed 3 years ago

evjava commented 3 years ago

Problem: code below failed during compile.

Message: Fatal error: exception File "X86.ml", line 677, characters 17-22: Pattern matching failed

Code:

` import Ref; import Array; import List; import Fun; import Collection; import Buffer;

fun argCompiler() { true } fun lookupFun(a, b) { true }

public fun compileSM0 (stmt, env) { case stmt of Call(fname, args) -> -- TODO is order of args ok? (maybe reverse) local argsCode = foldl(argCompiler, [{}, env], args); case lookupFun(env, fname) of Fun(fLabel, nargs) -> if nargs != size(args) then failure("expected %d arguments for function %s, found: %s", nargs, fname, size(args)) fi [argsCode +++ singleton(CALL (fname, size(args)))] esac esac } `

Version: commit 1849c7029b1d6cf0468e5587c1b2715e00a3b47e

dboulytchev commented 3 years ago

There is no ";" after "if ... then ... fi" expression in the body of innermost case; is it intended?

evjava commented 3 years ago

Nope ._.

dboulytchev commented 3 years ago

Fixed in 8f01e5eb5. An error is reported in this case.