Skip to content

feat: Add warning about NaN invariant and -0.0 for direct comparisons #2475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 31, 2022

Conversation

MaxGraey
Copy link
Member

@MaxGraey MaxGraey commented Aug 27, 2022

Produce warning like:

WARNING AS907: 'NaN' does not compare equal to any other value including itself. Use isNaN(x) instead.
      :
    2 │ assert(x != NaN);
      │        ~~~~~~~~
      └─ in index.ts(2,8)

and

WARNING AS907: 'NaN' does not compare equal to any other value including itself. Use isNaN(x) instead.
      :
    3 │ assert(x == NaN);
      │        ~~~~~~~~
      └─ in index.ts(3,8)

also

WARNING AS908: Comparison with -0.0 is sign insensitive. Use Object.is(x, -0.0) if the sign matters.
      :
    4 │ assert(x != -0.0);
      │        ~~~~~~~~~
      └─ in index.ts(4,8)
  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@MaxGraey MaxGraey marked this pull request as ready for review August 27, 2022 10:14
@MaxGraey MaxGraey requested a review from dcodeIO August 27, 2022 10:14
@MaxGraey MaxGraey changed the title feat: Add warning about NaN invariant during direct comparision feat: Add warning about NaN invariant and -0.0 during direct comparision Aug 27, 2022
@MaxGraey MaxGraey changed the title feat: Add warning about NaN invariant and -0.0 during direct comparision feat: Add warning about NaN invariant and -0.0 for direct comparisons Aug 27, 2022
@MaxGraey MaxGraey merged commit 6c79e39 into AssemblyScript:main Aug 31, 2022
@MaxGraey MaxGraey deleted the add-eq-to-NaN-warn branch August 31, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants