Skip to content

double-slash in import doesn't give analysis errors, but fails at compile/run time  #36337

Open
@DanTup

Description

@DanTup

Given the following files:

file1.dart

dantup-macbookpro:foo dantup$ cat file1.dart
import 'folder//file2.dart';

main() {
  a();
}

folder/file2.dart

import '../file3.dart';

a() {
  b();
}

file3.dart

b() {
  print('Hello!');
}

There are no analysis warnings about the double-slash in file1.dart1, however trying to run the file results in an error for the import inside file2.dart. It seems like the relative path starting ../ is not based from the correct folder when there are two slashes.

bin/foo/folder//file2.dart:1:8: Error: Error when reading 'bin/foo/folder/file3.dart': No such file or directory
import '../file3.dart';
       ^
bin/foo/folder//file2.dart:4:3: Error: Method not found: 'b'.
  b();
  ^

It seems like either the analysis server should also complain, or the code should compile/run successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-ux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions