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

Can't find import #200

Open
starper opened this issue Dec 18, 2017 · 1 comment
Open

Can't find import #200

starper opened this issue Dec 18, 2017 · 1 comment

Comments

@starper
Copy link

starper commented Dec 18, 2017

This error happens when there is an import from a parent folder. Let's say that we have a little project:

src\main.ipkg

package "main"

main = Main

opts = "--codegen javascript -o ../output/main.js"

modules = Main
        , Foo.Foo
        , Foo.Bar.Bar

src\Main.idr

module Main

import Foo.Foo
import Foo.Bar.Bar

baz1 : Int -> Int

main : JS_IO ()
main = do
  foo
  bar

src\Foo\Foo.idr

module Foo.Foo

%access export

baz2 : Int -> Int

foo : JS_IO ()
foo = pure ()

src\Foo\Bar\Bar.idr

module Foo.Bar.Bar

import Foo.Foo

%access export

baz3 : Int -> Int

bar : JS_IO ()
bar = foo

and we use Ctrl+Alt+A on baz1, baz2 and baz3. In case of baz1 and baz2 everything works as expected, but baz3 throws an error:

didn't load C:\Users\bla\bla\bla\src\Foo\Bar\Bar.idr
at line 0, file (no file)
Can't find import Foo\Foo

When you use Ctrl+Alt+A on baz1, baz2 and baz3, developer tools console prints something like this:

{ src : "C:\Users\Makar\repos\coin-hunter-idris\src" }
{ src : "C:\Users\Makar\repos\coin-hunter-idris\src\Foo" }
{ src : "C:\Users\Makar\repos\coin-hunter-idris\src\Foo\Bar" }

There is exectly the same error when you try to use idris Main.idr, idris Foo.idr, idris Bar.idr in command line (first two cases are ok, but the last one is complaining about import), but in this case it is expected behavior, since Idris (sadly) doesn't know anything about project root. The workaround is pretty simple: idris Bar.idr -i ../../

I think there could be two options of how to fix it:

  1. In settings add an option specifying a project root
  2. Use a convention that .ipkg file should be placed in a root directory and then search for it (I like this one better)

and then add -i root_dir to compiler options when calling Idris.

I'm not sure that I understand correctly how this plugin works, but I hope my suggestion is a good way to fix this bug. It's really annoying to have all this cool features and not being able to use them.

I use Windows 10, Idris 1.1.1, Atom 1.23.1 and atom-language-idris 0.4.10.

@justjoheinz
Copy link
Contributor

Thanks for the suggestion. AFAIk we already search for the ipkg. I check whether we also pass the -i option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants