Skip to content

Add a lint to ban num #57793

Open
Open
@a14n

Description

@a14n

From #57779

maybe a better lint to address my concern is one to ban num entirely (whether given explicitly or by inference).

Activity

a14n

a14n commented on Sep 21, 2018

@a14n
ContributorAuthor

@Hixie what would you put in lint's description of this lint to explain why num should be ban ?

Hixie

Hixie commented on Sep 21, 2018

@Hixie
Contributor

The primary idea is to avoid having code paths where the compiler needs to handle either int or double. cc @mraleph @a-siva @aam who might be able to confirm whether it's indeed more efficient to have code that unambiguously uses always int or always double or whether actually using num isn't such a big deal.

(The secondary reason here is to keep the code clear and catch likely bugs. It's often the case that if your code involves mixing int and double, you've probably stumbled into a less-than-fully-designed case that needs more thought.)

mraleph

mraleph commented on Sep 21, 2018

@mraleph
Member

For computational kernels it is indeed better to have code that uses either int or double not num.

TFA sometimes might be able to infer what is stored in a particular num typed location - but not always.

added
P3A lower priority bug or feature request
on Sep 22, 2022
added
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
and removed on Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagetype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pq@srawlins@mraleph@Hixie@a14n

        Issue actions

          Add a lint to ban num · Issue #57793 · dart-lang/sdk