Mercurial > projects > dang
comparison sema/TypeCheck.d @ 193:658178183018
Added error message for the case of calling a function pointer with wrong parameter count.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Fri, 25 Jul 2008 15:31:16 +0200 |
parents | e799db8d9cb0 |
children |
comparison
equal
deleted
inserted
replaced
192:fda35d57847e | 193:658178183018 |
---|---|
216 .arg(Integer.toString(i+1)); | 216 .arg(Integer.toString(i+1)); |
217 } | 217 } |
218 } | 218 } |
219 } | 219 } |
220 else if (iden.type.isCallable) | 220 else if (iden.type.isCallable) |
221 { | |
221 function_type = iden.type.asCallable(); | 222 function_type = iden.type.asCallable(); |
223 if (exp.args.length != function_type.params.length) | |
224 { | |
225 messages.report(CannotCallMethod, exp.loc) | |
226 .arg(iden.type.toString) | |
227 .arg(exp.callerType.toString); | |
228 } | |
229 } | |
222 else assert(0, "Should not happen"); | 230 else assert(0, "Should not happen"); |
223 | 231 |
224 foreach (i, arg; exp.args) | 232 foreach (i, arg; exp.args) |
225 { | 233 { |
226 auto argType = function_type.params[i]; | 234 auto argType = function_type.params[i]; |
419 assert(available.length, "No available methods in symbol-list."); | 427 assert(available.length, "No available methods in symbol-list."); |
420 | 428 |
421 Symbol[] possible; | 429 Symbol[] possible; |
422 Symbol perfect; | 430 Symbol perfect; |
423 | 431 |
432 bool per, work; | |
424 foreach (s ; available) | 433 foreach (s ; available) |
425 { | 434 { |
426 if (s.type.asFunction.params.length < arg_list.length) | 435 if (s.type.asFunction.params.length < arg_list.length) |
427 continue; | 436 continue; |
428 | 437 |
429 bool per = true; | 438 per = true; |
430 bool work = true; | 439 work = true; |
431 | 440 |
432 foreach (i, arg; arg_list) | 441 foreach (i, arg; arg_list) |
433 { | 442 { |
434 auto argType = s.type.asFunction.params[i]; | 443 auto argType = s.type.asFunction.params[i]; |
435 auto expType = arg.type; | 444 auto expType = arg.type; |