Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add workaround for bug #1811.

It can be actually proper fix due MMD distance for divide(Int, Default) vs divide(TclInt, TclFloat) can be same.

Requiares very recent parrot with exported PMC boxing functions.
  • Loading branch information...
commit 4b95281491e5ef1827be455d13b4fbb7b5337d91 1 parent 4069e65
Vasily Chekalkin bacek authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/pmc/tclint.pmc
17 src/pmc/tclint.pmc
View
@@ -38,7 +38,7 @@ pmclass TclInt
* TclInt shouldn't automatically promote division to float;
* also, explicitly use floor when dividing.
*/
- MULTI PMC *divide(Integer value, PMC* dest) {
+ MULTI PMC *divide(Integer *value, PMC* dest) {
FLOATVAL d = VTABLE_get_number(INTERP, value);
if (d == 0)
@@ -51,6 +51,21 @@ pmclass TclInt
VTABLE_set_integer_native(INTERP, dest, floor(SELF.get_integer() / d));
return dest;
}
+
+ /*
+ * Workaround for bug #1811 when "div TclInt, TclFloat" dispatched
+ * to Integer.divide(DEFAULT).
+ */
+ MULTI PMC *divide(DEFAULT *value, PMC* dest) {
+ FLOATVAL d = VTABLE_get_number(INTERP, value);
+
+ if (d == 0)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
+ "divide by zero");
+
+ dest = Parrot_pmc_box_number(INTERP, SELF.get_integer() / d);
+ return dest;
+ }
}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.