Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V Module Resolution follows symlink and compiles successfully #5675

Open
iocat opened this issue Jul 5, 2020 · 3 comments
Open

V Module Resolution follows symlink and compiles successfully #5675

iocat opened this issue Jul 5, 2020 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@iocat
Copy link

iocat commented Jul 5, 2020

V version: v0.1.28
OS: MacOS X

What did you do?

// vcode/codewithmodule.v
package main

import mymodule

fn main(){
  mymodule.say_hello()
}
// vcode/mymodule/code.v
package mymodule

pub fn say_hello(){
  println("Hello world")
}

Then create a symlink outside of code folder, and compile the symlink'ed V file

ln -s vcode/codewithmodule.v code.v
v -o code code.v
./code

What did you expect to see?

The compiler should error out that the module is not found because the module dependency is not directly there.

What did you see instead?

./code prints "Hello World" just fine, which means the compiler follows the symlink of the file, and then compiles the symlinked code.

I think we should read the symlink contents as is and not take into account the path as a result of a symbolic link.

@iocat iocat added the Bug This tag is applied to issues which reports bugs. label Jul 5, 2020
@div72
Copy link
Contributor

div72 commented Jul 5, 2020

  1. I don't see this as an issue. It compiles the code in the symlink, but the module is still in cwd.
  2. Are you sure you're on V? It should be module instead of package.

@iocat
Copy link
Author

iocat commented Jul 5, 2020

  1. The module mymodule was not in $(pwd), but it is next to the symlink destination. The execution context I used to repro. was vcode/...
    vcode/.. doesn't have the mymodule module, but still compiles just fine.

I think certain build tool, like Google's Bazel, uses symlink to simulate a hermetic environment for a build target in a multi-project or multi-language monorepo. So it'll be useful to be symlink-agnostic maybe via an opt-out mechanism.

Node has similar issue that fixes via a flag: https://nodejs.org/api/cli.html#cli_preserve_symlinks
Jest-lang: jestjs/jest#5356

  1. Oops, sorry. I got some Go habit there. That should have been a module.

@ArtemkaKun
Copy link
Contributor

Hi @iocat ,

can you confirm that problem exists on a fresh V (0.2.4)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

3 participants