Detect and report module names that don't match what they are used as

Prior to this commit, if you had a module structure like

```
| - A.roc
| - Dep
    | - B.roc
```

where `B.roc` was defined as

```
interface B exposes [] imports []
```

and `A.roc` was defined as

```
interface A exposes [] imports [Dep.B]
```

The compiler would hang on you. The reason is that even though we expect
`B` to be named `Dep.B` relative to `A`, that would not be enforced.

With this patch, we now enforce such naming schemes - a module must have
the namespaced name it is referenced by. Currently, we determine the
expected namespaced name by looking at how transitive dependencies of the
root module reference the module. In the future, once we have a package
ecosystem and a solid idea of "package roots", we can use the "package
root" to determine how a module should be named.

Closes #4094
This commit is contained in:
Ayaz Hafiz 2022-09-28 12:38:01 -05:00
parent a5ebd7f477
commit 0cc9ea4b05
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 227 additions and 18 deletions

View file

@ -2,7 +2,7 @@ use roc_region::all::{Position, Region};
use std::fmt;
/// A position in a source file.
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct State<'a> {
/// The raw input bytes from the file.
/// Beware: original_bytes[0] always points the the start of the file.