comparison sema/TypeCheck.d @ 177:491b5fc4782a

Small fixes to type checks.
author Anders Johnsen <skabet@gmail.com>
date Thu, 24 Jul 2008 23:36:10 +0200
parents dc9bf56b7ace
children 2a1a635bd531
comparison
equal deleted inserted replaced
176:dc9bf56b7ace 177:491b5fc4782a
127 { 127 {
128 foreach (i, arg; exp.args) 128 foreach (i, arg; exp.args)
129 { 129 {
130 auto argType = sel.type.asFunction.params[i]; 130 auto argType = sel.type.asFunction.params[i];
131 auto expType = arg.type; 131 auto expType = arg.type;
132 if (argType.byteSize != expType.byteSize) 132 if (argType.isSame(expType))
133 { 133 {
134 if (!expType.hasImplicitConversionTo(argType)) 134 if (!expType.hasImplicitConversionTo(argType))
135 messages.report(InvalidImplicitCast, exp.loc) 135 messages.report(InvalidImplicitCast, exp.loc)
136 .arg(expType.toString) 136 .arg(expType.toString)
137 .arg(argType.toString); 137 .arg(argType.toString);
220 220
221 foreach(i, arg; exp.args) 221 foreach(i, arg; exp.args)
222 { 222 {
223 auto argType = exp.exp.type.asFunction.params[i]; 223 auto argType = exp.exp.type.asFunction.params[i];
224 auto expType = arg.type; 224 auto expType = arg.type;
225 if(argType.byteSize != expType.byteSize) 225 if(!argType.isSame(expType))
226 { 226 {
227 if(!expType.hasImplicitConversionTo(argType)) 227 if(!expType.hasImplicitConversionTo(argType))
228 messages.report(InvalidImplicitCast, exp.loc) 228 messages.report(InvalidImplicitCast, exp.loc)
229 .arg(expType.toString) 229 .arg(expType.toString)
230 .arg(argType.toString); 230 .arg(argType.toString);
264 { 264 {
265 foreach (i, arg; exp.c_args) 265 foreach (i, arg; exp.c_args)
266 { 266 {
267 auto argType = sel.type.asFunction.params[i]; 267 auto argType = sel.type.asFunction.params[i];
268 auto expType = arg.type; 268 auto expType = arg.type;
269 if (argType.byteSize != expType.byteSize) 269 if (!argType.isSame(expType))
270 { 270 {
271 if (!expType.hasImplicitConversionTo(argType)) 271 if (!expType.hasImplicitConversionTo(argType))
272 messages.report(InvalidImplicitCast, exp.loc) 272 messages.report(InvalidImplicitCast, exp.loc)
273 .arg(expType.toString) 273 .arg(expType.toString)
274 .arg(argType.toString); 274 .arg(argType.toString);
327 327
328 if(stmt.exp) 328 if(stmt.exp)
329 { 329 {
330 auto returnType = stmt.env.parentFunction.type.asFunction.returnType; 330 auto returnType = stmt.env.parentFunction.type.asFunction.returnType;
331 auto expType = stmt.exp.type; 331 auto expType = stmt.exp.type;
332 if(returnType != expType) 332 if(!returnType.isSame(expType))
333 { 333 {
334 if(!expType.hasImplicitConversionTo(returnType)) 334 if(!expType.hasImplicitConversionTo(returnType))
335 messages.report(InvalidImplicitCast, stmt.exp.loc) 335 messages.report(InvalidImplicitCast, stmt.exp.loc)
336 .arg(expType.toString) 336 .arg(expType.toString)
337 .arg(returnType.toString); 337 .arg(returnType.toString);
352 352
353 if(decl.init) 353 if(decl.init)
354 { 354 {
355 auto varType = decl.identifier.type; 355 auto varType = decl.identifier.type;
356 auto expType = decl.init.type; 356 auto expType = decl.init.type;
357 if(varType.byteSize != expType.byteSize) 357 if(!varType.isSame(expType))
358 { 358 {
359 if(!expType.hasImplicitConversionTo(varType)) 359 if(!expType.hasImplicitConversionTo(varType))
360 messages.report(InvalidImplicitCast, decl.init.loc) 360 messages.report(InvalidImplicitCast, decl.init.loc)
361 .arg(expType.toString) 361 .arg(expType.toString)
362 .arg(varType.toString); 362 .arg(varType.toString);
394 394
395 foreach (i, arg; arg_list) 395 foreach (i, arg; arg_list)
396 { 396 {
397 auto argType = s.type.asFunction.params[i]; 397 auto argType = s.type.asFunction.params[i];
398 auto expType = arg.type; 398 auto expType = arg.type;
399 if (argType != expType) 399 if (argType.isSame(expType))
400 { 400 {
401 per = false; 401 per = false;
402 if( !expType.hasImplicitConversionTo(argType) ) 402 if( !expType.hasImplicitConversionTo(argType) )
403 { 403 {
404 work = false; 404 work = false;