Skip to content

Dart uses raw URIs for library identity. #939

@lrhn

Description

@lrhn

Dart currently identifies libraries by their import URI.
That causes troubles in some situations:

I suggest that we loosen the language specification to the point where the compiler is in charge of detecting when two URIs represent the same library, and it is allowed to canonicalize the URI of the library prior to resolving imports.

If the compiler can recognize that the underlying file system is case insensitive, then it is free (and encouraged) to consider Foo.dart and foo.dart the same library. It might still want to give a warning/hint that the code won't work on case-sensitive platforms.

If someone runs or imports lib/main.dart, the compiler is free to rewrite that to package:currentPackage/main.dart. We already do that for entry points (see also dart-lang/sdk#37978), but it sometimes fails for direct imports from the bin/ directory or other cases.

In general, allow the compiler to recognize that two URIs are actually referring the same library file using any available information, not just what the language specification can predict.
It still have to be in some way predictable. Generally, if it's the same underlying file, then it should be the same library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions