diff --git a/compiler/expressions.cpp b/compiler/expressions.cpp index 43104f3a..9082bbe1 100644 --- a/compiler/expressions.cpp +++ b/compiler/expressions.cpp @@ -100,6 +100,11 @@ bool find_userop(SemaContext& sc, int oper, Type* type1, Type* type2, int numpar size_t i; bool savepri, savealt; + if (type1->isReference()) + type1 = type1->inner(); + if (type2 && type2->isReference()) + type2 = type2->inner(); + /* since user-defined operators on untagged operands are forbidden, we have * a quick exit. */ diff --git a/tests/regressions/overload-float-ref.out b/tests/regressions/overload-float-ref.out new file mode 100644 index 00000000..1f06a5d4 --- /dev/null +++ b/tests/regressions/overload-float-ref.out @@ -0,0 +1,2 @@ +143.750000 +10143.750000 diff --git a/tests/regressions/overload-float-ref.sp b/tests/regressions/overload-float-ref.sp new file mode 100644 index 00000000..78678495 --- /dev/null +++ b/tests/regressions/overload-float-ref.sp @@ -0,0 +1,13 @@ +#include + +void test(float& damage) { + printf("%f\n", damage); + int new_damage = 10000; + damage += float(new_damage); + printf("%f\n", damage); +} + +public main() { + float damage = 143.75; + test(damage); +}