From 7652f7e935684d3c7851fbcad8ddce97e510a5a6 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Fri, 18 Jun 2010 20:32:46 -0400 Subject: [PATCH] print recur mismatch warnings, for now --- src/jvm/clojure/lang/Compiler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index fff8e62fb2..311505cf83 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -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{ @@ -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()); @@ -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) @@ -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); } } }