Skip to content

Commit

Permalink
Merge pull request #5403 from unisonweb/fix-5402
Browse files Browse the repository at this point in the history
  • Loading branch information
aryairani authored Oct 9, 2024
2 parents 92e08be + ed765ab commit 99c676f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parser-typechecker/src/Unison/Syntax/FileParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ file = do
maybeNamespace :: Maybe Name.Name <-
optional (reserved "namespace") >>= \case
Nothing -> pure Nothing
Just _ -> Just . L.payload <$> (importWordyId <|> importSymbolyId)
Just _ -> do
namespace <- importWordyId <|> importSymbolyId
void (optional semi)
pure (Just (L.payload namespace))
let maybeNamespaceVar = Name.toVar <$> maybeNamespace

-- The file may optionally contain top-level imports,
Expand Down
13 changes: 13 additions & 0 deletions unison-src/transcripts/fix-5402.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
`namespace` + top level `use` should work. Previously, they didn't.

```unison
namespace foo
use bar baz
x = 10
```

```unison
use bar baz
namespace foo
x = 10
```
40 changes: 40 additions & 0 deletions unison-src/transcripts/fix-5402.output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
`namespace` + top level `use` should work. Previously, they didn't.

``` unison
namespace foo
use bar baz
x = 10
```

``` ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
foo.x : ##Nat
```
``` unison
use bar baz
namespace foo
x = 10
```

``` ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
foo.x : ##Nat
```

0 comments on commit 99c676f

Please sign in to comment.