Skip to content

Commit

Permalink
print recur mismatch warnings, for now
Browse files Browse the repository at this point in the history
  • Loading branch information
richhickey committed Jun 19, 2010
1 parent c79d287 commit 7652f7e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/jvm/clojure/lang/Compiler.java
Expand Up @@ -5488,10 +5488,15 @@ public boolean canEmitPrimitive(){
public static class RecurExpr implements Expr{
public final IPersistentVector args;
public final IPersistentVector loopLocals;
final int line;
final String source;


public RecurExpr(IPersistentVector loopLocals, IPersistentVector args){
public RecurExpr(IPersistentVector loopLocals, IPersistentVector args, int line, String source){
this.loopLocals = loopLocals;
this.args = args;
this.line = line;
this.source = source;
}

public Object eval() throws Exception{
Expand Down Expand Up @@ -5536,11 +5541,12 @@ else if(primc == float.class && pc == double.class)
}
else
{
if(RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))
if(true)//RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))
//throw new IllegalArgumentException
RT.errPrintWriter().println
("recur arg for primitive local: " +
lb.name + " must be matching primitive, had: " +
(source + ":" + line +
" recur arg for primitive local: " +
lb.name + " is not matching primitive, had: " +
(arg.hasJavaClass() ? arg.getJavaClass().getName():"Object") +
", needed: " +
primc.getName());
Expand Down Expand Up @@ -5587,6 +5593,9 @@ public Class getJavaClass() throws Exception{

static class Parser implements IParser{
public Expr parse(C context, Object frm) throws Exception{
int line = (Integer) LINE.deref();
String source = (String) SOURCE.deref();

ISeq form = (ISeq) frm;
IPersistentVector loopLocals = (IPersistentVector) LOOP_LOCALS.deref();
if(context != C.RETURN || loopLocals == null)
Expand All @@ -5602,7 +5611,7 @@ public Expr parse(C context, Object frm) throws Exception{
throw new IllegalArgumentException(
String.format("Mismatched argument count to recur, expected: %d args, got: %d",
loopLocals.count(), args.count()));
return new RecurExpr(loopLocals, args);
return new RecurExpr(loopLocals, args, line, source);
}
}
}
Expand Down

0 comments on commit 7652f7e

Please sign in to comment.