diff --git a/sources/zweic/Analyzer.scala b/sources/zweic/Analyzer.scala index 7a3001d..8718328 100755 --- a/sources/zweic/Analyzer.scala +++ b/sources/zweic/Analyzer.scala @@ -193,8 +193,8 @@ } if ( !args.map(x => analyzeExpr(varScope, x)).zip(v.paramtypes) .forall( x:Pair[Type,Type] => x._1.isSubtype(x._2)) ) { - Report.error(tree.pos, "Incompatible Types: \nrequired:" + v.allFields.foldLeft("", (a,b)=>a + b) + - "\nfound:" + args.foldRight("", (a,b)=>a + b) ); + Report.error(tree.pos, "Incompatible Types: \nrequired:" + v.paramtypes.foldLeft("")((a,b)=>a + b) + + "\nfound:" + args.foldLeft("")((a,b)=>a + b) ); IBadType; } name.sym = v; @@ -210,14 +210,15 @@ } case New(name, args) => - classScope.get(name.name) match { + val ct = classScope.get(name.name); + ct match { case Some(v) => if (args.length != v.allFields.length) { Report.error(tree.pos, "Wrong number of arguments for class constructor in " + ct); IBadType } - if ( args.map(x => analyzeExpr(varScope, x)).zip(v.allFields) - .forall((a:Type, b:Type) => a.isSubtype(b)) ) { + if ( args.map(x => analyzeExpr(varScope, x)).zip(v.allFields.map(y => y.fieldtype)) + .forall( x:Pair[Type, Type] => x._1.isSubtype(x._2)) ) { Report.error(tree.pos, "Incompatible Types: \nrequired:" + v.allFields + "\nfound:" + args); IBadType; @@ -237,7 +238,7 @@ IIntType case Unop(op, expr) => - checkIntType(tree.pos, analyzeExpr(varScope, expr)) + checkIntType(tree.pos, analyzeExpr(varScope, expr)); IIntType case Binop(op, left, right) => @@ -252,15 +253,15 @@ } IIntType - case ReadInt => + case ReadInt() => IIntType - case ReadChar => + case ReadChar() => IIntType case If(cond, stata, statb) => - checkIntType(analyzeExpr(varScope, cond)); - analyzeExpr(varScope, stata).lub(analyzeExpr(varScope, statb)) + checkIntType(cond.pos, analyzeExpr(varScope, cond)); + analyzeExpr(varScope, stata).lub(analyzeExpr(varScope, statb)).get; case Block(stats, expr) => analyzeExpr(stats.foldLeft(varScope)(analyzeStat), expr)