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

fix(compiler): Raise appropriate exception when modules are missing during dependency graph construction #1485

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

peblair
Copy link
Member

@peblair peblair commented Nov 20, 2022

Fixes #1480. Additionally, this PR modifies the missing module error message to contain the correct source locations. For example, given the following files:
tst.gr:

import Number from "./numberr"
print(Number.min(2, 3))

numberr.gr:

import Number from "number"
import Foo from "foo" // <- does not exist
export let min = Number.min

The following error is reported:

 λ grain git:(philip/file-missing-import) > grain tst.gr
File "././numberr.gr", line 2, characters 16-21:
Error: Missing file for module foo

@peblair peblair requested a review from a team November 20, 2022 17:29
@phated
Copy link
Member

phated commented Nov 20, 2022

Should we normalize the path? In the example "././numberr.gr" should probably remove one of the ./

Copy link
Member

@marcusroberts marcusroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I rebased and tested it with my LSP fix and things look great in the problems tab.

Screen Shot 2022-11-29 at 2 20 39 PM

I can't replicate the duplicate relativity in the example (././numberr.gr) because my file paths are always absolute. If Philip or anyone else can replicate, please open an issue explaining how you did it.

@phated phated merged commit d8cd8f1 into main Nov 29, 2022
@phated phated deleted the philip/file-missing-import branch November 29, 2022 21:52
@github-actions github-actions bot mentioned this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Compiler: Give pretty error when file does not exist
4 participants