Repository navigation
Conversation
b78f827 to
d93cde7
Compare
854e317 to
7efb825
Compare
CBinOp::expected_operand_types and handle pointers/complex numberse62b79c to
85e05aa
Compare
d79be12 to
fa2af73
Compare
ahomescu
left a comment
There was a problem hiding this comment.
Could you add a test or two for this (unit and/or snapshot)?
|
Not really sure what to test for, that isn't already tested? |
46b0ce9 to
31c8fbb
Compare
31c8fbb to
e5c1d4e
Compare
|
Okay we can land this as is since it's a pretty small change, but it would be nice in the future if changes were split between 1) refactorings (no tests needed), and 2) actual functional changes, that would need a test or two to handle those specific corner cases. |
| // See if a `Complex` version of the new result type exists. | ||
| if matches!(result_type_kind, CTypeKind::Complex(..)) { | ||
| let new_result_type_kind = | ||
| CTypeKind::Complex(result_type_id.ctype); |
There was a problem hiding this comment.
What if result_type_id is already a Complex? Would something like double f(double _Complex a, double _Complex b) { ... a + b ... } panic here? That could be a new test.
There was a problem hiding this comment.
If it's already a Complex then it would either stay the same, or be replaced with the complex version of one of the PULLBACK_KINDS, same as happens with other numeric types right now. The code here only applies to binary operators, so it won't modify a function call.
There was a problem hiding this comment.
My point was: is it incorrect to create a type like CTypeKind::Complex(Complex(...))?
There was a problem hiding this comment.
Can you check if the following C functions cause transpiler panics?
double _Complex f(double _Complex a, double _Complex b) {
return a * b;
}
double _Complex g(double a, double _Complex b) {
return a * b;
}
typedef double real;
double _Complex h(double _Complex a, real b) {
return a * b;
}There was a problem hiding this comment.
Hmm, it does, and I see the problem now. I managed to fix the first two cases, but the third one still panics because of the typedef. No real _Complex type exists. I need to think of a way around that...
There was a problem hiding this comment.
Ok, I've completely rewritten that part of the code. It should be good now?
e5c1d4e to
8847410
Compare
8847410 to
eddb91a
Compare
eddb91a to
ced080a
Compare
921a686 to
f5895cd
Compare
f5895cd to
d4efdf5
Compare
Both a refactor and a functional improvement. Complex numbers aren't supported yet, so I haven't included any tests for that, but this is needed to support them later.