Conversation
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
|
Could you add to functional-test-suite/src/commonMain/resources/types/float/ops/ ? That'd make sure the corner cases are exercised for all backends. |
|
Worth noting that in theory this solves #373 in theory and maybe should add a specific test there. Leaving this as a note so its linked in GH history. |
tjpalmer
left a comment
There was a problem hiding this comment.
Some of these changes are good, some are meh, some are bad, and some I still haven't looked at enough.
If you have different opinions on any, let me know.
Minimally, this maybe can serve as an example of why not to just do everything that AI says. Which should help for some talking points of why Temper still matters.
| var abs = absTol ?? 0.0; | ||
| var margin = Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)) * rel, abs); | ||
| return Math.Abs(x - y) < margin; | ||
| return Math.Abs(x - y) <= margin; |
There was a problem hiding this comment.
This does match Python's math.isclose better. I'll plan to see if everything else also gets updated in this pr.
| : trimmed == "-Infinity" | ||
| ? double.NegativeInfinity | ||
| : double.Parse(s); | ||
| : double.Parse(trimmed); |
There was a problem hiding this comment.
In Remarks here, it says that double.Parse allows for surrounding whitespace, so it doesn't matter much whether s or trimmed goes in. Maybe worth a comment either way, and maybe trimmed is less surprising. So probably an ok change to make, even if s also works.
| { | ||
| count += 1; | ||
| if (i + 1 < right) | ||
| if (i + 1 < limit) |
There was a problem hiding this comment.
Because the loop prevents i from going past limit, either works fine here, so again, a needless change but also not a breaking one. And maybe limit is less surprising to some people.
| { | ||
| return -1; | ||
| return i; | ||
| } |
There was a problem hiding this comment.
I personally feel a lot better always using -1 for no string index rather than arbitrary negative values. Is there a good reason for this change that I'm missing? If not, I'd like to revert this.
There was a problem hiding this comment.
I agree with Tom on this.
| } | ||
| const margin = Math.max(Math.max(Math.abs(x), Math.abs(y)) * relTol, absTol); | ||
| return Math.abs(x - y) < margin; | ||
| return Math.abs(x - y) <= margin; |
There was a problem hiding this comment.
So we've updated cs and js so far.
| val calleeTree = callToInline.definition | ||
| val formalNameToArg = callToInline.formalNameToFunArg | ||
| val thisBindings = callToInline.thisTypeBindings | ||
| callToInline.thisTypeBindings |
There was a problem hiding this comment.
This looks like good cleanup at a glance.
| else -> type | ||
| } | ||
| is OrType -> type.members.firstNotNullOf { findNominal(it) } | ||
| is OrType -> type.members.firstNotNullOfOrNull { findNominal(it) } |
There was a problem hiding this comment.
I haven't analyzed to know if this is a good change or not.
| // larger shift or comparison operator, or close tag start marker. | ||
| val before = text[end - 1] | ||
| val after = if (end + 1 < limit) { text[end - 1] } else { '\u0000' } | ||
| val after = if (end + 1 < limit) { text[end + 1] } else { '\u0000' } |
There was a problem hiding this comment.
The old code looks sus, but I don't know why it wouldn't have triggered problems. No test changes from this?
There was a problem hiding this comment.
Nope, no changes, it's one of those "how did it ever work?!" things.
| fun append(str: String) { buffer.append(str) } | ||
|
|
||
| @Synchronized | ||
| override fun toString(): String = "$buffer" |
There was a problem hiding this comment.
Again, some analysis here would be good, which I haven't done right now.
There was a problem hiding this comment.
It makes sure the buffer is never read at the same the above append is happening, as that would be bad and give you a toString() that never actually existed.
There was a problem hiding this comment.
It makes sure the buffer is never read at the same the above append is happening, as that would be bad and give you a toString() that never actually existed.
I guess the question is if it's ever used from multithreaded contexts. I still haven't looked, though.
There was a problem hiding this comment.
For the time being it feels like it could be, as the @Synchronized on the other method is preexisting. If it weren't used multithreaded then both should be removed.
Signed-off-by: Shaw Summa <shawsumma@gmail.com>
Maybe a corner case test for |
Signed-off-by: Tom <tom@contextfree.info>
|
|
||
| function temper.string_indexof(str, target, i) | ||
| return string.find(str, target, i, true) or 0 | ||
| return string.find(str, target, i, true) or -1 |
There was a problem hiding this comment.
For lua, I think we're using 0 as no string index, since indices start at 1?
There was a problem hiding this comment.
I liked having it be -1 everywhere, tho maybe this needs more thought
There was a problem hiding this comment.
Does this affect == with NoStringIndex
There was a problem hiding this comment.
Does this affect
==with NoStringIndex
I put an approve, but maybe this is worth testing somewhere sometime if we don't yet.
| TmpLOperator.AmpAmp -> TODO() // RustOperator.LogicalAnd | ||
| TmpLOperator.BarBar -> TODO() // RustOperator.LogicalOr | ||
| TmpLOperator.AmpAmp -> RustOperator.LogicalAnd | ||
| TmpLOperator.BarBar -> RustOperator.LogicalOr |
There was a problem hiding this comment.
I see here's where they were being ignored before. Looks like we don't actually translate to using these. Instead we assign bool values from if/else sequences. But probably good to implement these anyway, just in case, and even if not easy to test, the implementations look ok.
* Maybe address RustTranslator concerns * Take out redundant rust things, also mapDropping Signed-off-by: Tom <tom@temper.systems>
tjpalmer
left a comment
There was a problem hiding this comment.
There's still a lot of complicated stuff here, but I'm ready to call it good enough, anyway. Maybe we can restrict the number or variety of AI changes in single PRs in the future some.
I have some old pending comments here I also forgot to submit earlier, but meh.
| } | ||
| } | ||
| Arc::new(result) | ||
| } |
There was a problem hiding this comment.
We got by without it because nothing has ever tested mapDropping. The above is also incorrect, because it's based on Option instead of Result. I'll back out the mapDropping changes from this branch, because it would increase scope. At least be-csharp also doesn't implement mapDropping. I haven't tested all backends yet.
| } | ||
| } | ||
|
|
||
| private val print: SupportCode = PrintCode |
There was a problem hiding this comment.
Yeah, print also is a relic that we no longer produce. Not sure about the other compares, but as they're not being used, I'm feeling too busy to study and remove them from this pr. Just leaving this comment here, so people can know that they haven't ever really been tested.
I used the AI to identify and fix small problems in the backends, mostly focusing on correctness, but also doing some inlining.