onflow/cadence-tools

[LS] Cannot use new import syntax & path imports together

Opened this issue · 2 comments

Current Behavior

Due to the design of the LS & how sema.Checker locations are set at runtime, a contract imported using the new import syntax cannot import a contract using relative path imports (aka file imports).

Expected Behavior

You should be able to use relative path imports & new import syntax together.

This is especially important if somebody copy + pastes core contracts into their project. These contracts may import each other and be using the path import syntax -> causes downstream error -> causes confusion.

Steps To Reproduce

A.cdc

import "B"            // will have a diagnostic error in vscode because of imported contract not being able to resolve C.cdc properly
pub contract A {}

B.cdc

import C from "../foo/C.cdc"
pub contract B {}

C.cdc

pub contract C {}

Environment

- LS version: v0.32.0
- Network: n/a

This hit me today when trying to debug whey imports using a mix of paths and "new import syntax" did not work.