You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Every Js.Date is equal to every other Js.Date #3455
hi, = is unsafe unless you know what you do. We have a warning flag (102) to warn unsafe usage of =, we accept patches to make the default behavior less surprising
After O.isArray one would check O.isDate which presumably would use instanceof Date.
Date equality does not work with == in JS so one would need to use <= and >=.
One option to kind of cover this and other surprises with polymorphic compares is to by default enable 102 as a warning. Actually, now that I think about it, I want to propose some stricter warnings and errors by default anyway. I'll open a separate issue.
@bobzhang that makes sense actually–I had it turned on for a bit and realized it's not great because the warning doesn't go away–it keeps appearing even if the file isn't touched afterwards 😅
Activity
bobzhang commentedon Mar 29, 2019
hi,
=is unsafe unless you know what you do. We have a warning flag (102) to warn unsafe usage of=, we accept patches to make the default behavior less surprisingyawaramin commentedon Mar 29, 2019
More details on the unsafety here https://blog.janestreet.com/the-perils-of-polymorphic-compare/
cristianoc commentedon Mar 29, 2019
For reference: this is the point where dates would be handled:
https://github.com/BuckleScript/bucklescript/blob/fafc9fd350a29275bb523c17564aed27879efc96/jscomp/runtime/caml_obj.ml#L328
After
O.isArrayone would checkO.isDatewhich presumably would useinstanceof Date.Date equality does not work with
==in JS so one would need to use<=and>=.bobzhang commentedon Apr 3, 2019
It makes sense to make the default less surprising, we are going to have this fixed in next release
yawaramin commentedon Apr 3, 2019
One option to kind of cover this and other surprises with polymorphic compares is to by default enable 102 as a warning. Actually, now that I think about it, I want to propose some stricter warnings and errors by default anyway. I'll open a separate issue.
bobzhang commentedon Apr 4, 2019
@yawaramin it used to be default, but people don't like it ..
yawaramin commentedon Apr 5, 2019
@bobzhang that makes sense actually–I had it turned on for a bit and realized it's not great because the warning doesn't go away–it keeps appearing even if the file isn't touched afterwards 😅
fix #3455
Merge pull request #3475 from BuckleScript/fix_3455