Skip to content

Strange error with "Instance of '_SimpleUri'" for malformed import. #59606

@rakudrama

Description

@rakudrama

This error message contains Instance of '_SimpleUri'

$ out/ReleaseX64/dart-sdk/bin/dart --packages=/usr/local/google/home/sra/Dart2/sdk/.dart_tool/package_config.json ~/play1/bug1a3v.dart
Error: Invalid package URI 'package:collection':
  Invalid argument (packageUri): Package URIs must start with the package name followed by a '/': Instance of '_SimpleUri'.
../../play1/bug1a3v.dart:1:8: Error: Not found: 'package:collection'
import 'package:collection';
       ^

Source file:

import 'package:collection';
main() {}

If I escape characters in the URI (e.g. replace n with %6E), I can get an error message saying Instance of '_Uri'.

Could Error.toSafeString trust a Uri?
Or perhaps the front-end should format it, since it has the source file string, more like it reports an unparseable URI.

/cc @lrhn @johnniwinther

Metadata

Metadata

Assignees

No one assigned

    Labels

    legacy-area-front-endLegacy: Use area-dart-model instead.model-messagesPoor/undesirable messaging in errors/warnings emitted by the analyzer and/or CFE.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions