Skip to content

Improved static type checking (strict mode?) #42

@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


Excerpt: http://www.dartlang.org/articles/optional-types/


   If you love types, you may use them everywhere, much like in a statically typed language. However, even then you won’t get the same level of static checking. Dart’s rules are much less rigid. We anticipate providing additional tools that might interpret type annotations more strictly for those who like that sort of thing.


Problem code:
    Object foo(){return "x";}
    String s = foo();

This type of 'relaxed' type checking makes the type system almost useless. If you're going to implement static type checking, then at no point should it be acceptable to take a return value of type 'Object' and implicitly assume it might be a 'String'.

I can completely get behind making types optional. This should be done via the Dynamic keyword. Even you remark that "new List();" is just a shorthand for "new List<Dynamic>();" I can agree with a return value of type 'Dynamic' being assigned to a 'String' type without an error/warning.

Acceptable:
    Dymanic foo(){ return "x";}
    String s= foo();

Please implement strict static type checking before people start writing libraries. This would greatly appease those of us "... who like that sort of thing".

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-not-plannedClosed as we don't intend to take action on the reported issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions