onflow / cadence-tools

Developer tools for Cadence
https://www.onflow.org/
Apache License 2.0
24 stars 20 forks source link

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

Open jribbink opened 10 months ago

jribbink commented 10 months ago

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
bjartek commented 6 months ago

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

jribbink commented 6 months ago

https://discord.com/channels/613813861610684416/1204034793856180224

cc @gregsantos is this something we should try to prioritize?