-
Notifications
You must be signed in to change notification settings - Fork 27
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
Added aliased import #258
Added aliased import #258
Conversation
It is releated with #219 |
Checklist 🤔
|
afd38bf
to
a69542e
Compare
Codecov Report
@@ Coverage Diff @@
## master #258 +/- ##
==========================================
+ Coverage 75.84% 76.16% +0.31%
==========================================
Files 33 33
Lines 2414 2446 +32
Branches 132 132
==========================================
+ Hits 1831 1863 +32
Misses 451 451
Partials 132 132
Continue to review full report at Codecov.
|
a69542e
to
6b824da
Compare
test/Nirum/Package/ModuleSetSpec.hs
Outdated
, Import ["baz"] "qux" empty | ||
] Nothing | ||
, Module | ||
[ Import ["foo", "bar"] "xyz" "xyz" empty --MissingModulePathError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a space right after --
.
src/Nirum/Parser.hs
Outdated
return [Import path ident aSet | (ident, aSet) <- idents] | ||
return [ Import path source imp aSet | ||
| (imp, source, aSet) <- idents | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have tests for all combinations of the following conditions:
Empty parentheses | Single import name w/o trailing comma | Single import name w/ trailing comma | Multiple import names w/o trailing comma | Multiple import names w/ trailing comma | |
---|---|---|---|---|---|
With as |
import foo () |
import foo (x as a) |
import foo (x as a,) |
import foo (x as a, y as b, c) |
import foo (x as a, y as b, c,) |
Without as |
import foo() |
import foo (a) |
import foo(a, b, c,) |
import foo (a,) |
import foo(a, b, c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test if the parser disallows and shows an error when there are duplicated alias names.
1e581a8
to
77b5274
Compare
77b5274
to
25da998
Compare
test/Nirum/Constructs/ModuleSpec.hs
Outdated
, (["zzz"], ["qqq", "ppp"]) | ||
imports mod1 `shouldBe` [ (["foo", "bar"], [ ("baz", "baz") | ||
, ("qux", "qux") | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/Constructs/ModuleSpec.hs
Outdated
, (["xyz"], [("asdf", "asdf")]) | ||
, (["zzz"], [ ("qqq", "qqq") | ||
, ("ppp", "ppp") | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
Nothing -> toType | ||
coreModulePath | ||
identifier | ||
(DS.lookup identifier $ types coreModule) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/Package/ModuleSetSpec.hs
Outdated
, (["qux"], Module [ Import ["foo"] "abc" empty -- MissingImportError | ||
, Import ["foo"] "def" empty -- MissingImportError | ||
, (["qux"], Module [ Import ["foo"] "abc" "abc" empty -- MissingImportError | ||
, Import ["foo"] "def" "def" empty -- MissingImportError | ||
] Nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/Package/ModuleSetSpec.hs
Outdated
] Nothing) | ||
] | ||
|
||
circularImportsModules :: [(ModulePath, Module)] | ||
circularImportsModules = | ||
[ (["asdf"], Module [ Import ["asdf"] "foo" empty | ||
[ (["asdf"], Module [ Import ["asdf"] "foo" "foo" empty | ||
, TypeDeclaration "bar" (Alias "text") empty | ||
] Nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/Package/ModuleSetSpec.hs
Outdated
, TypeDeclaration "bar" (Alias "text") empty | ||
] Nothing) | ||
, (["abc", "def"], Module [ Import ["abc", "ghi"] "bar" empty | ||
, (["abc", "def"], Module [ Import ["abc", "ghi"] "bar" "bar" empty | ||
, TypeDeclaration | ||
"foo" (Alias "text") empty | ||
] Nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/Package/ModuleSetSpec.hs
Outdated
, TypeDeclaration | ||
"bar" (Alias "text") empty | ||
] Nothing) | ||
, (["abc", "xyz"], Module [ Import ["abc", "def"] "foo" empty | ||
, (["abc", "xyz"], Module [ Import ["abc", "def"] "foo" "foo" empty | ||
, TypeDeclaration | ||
"baz" (Alias "text") empty | ||
] Nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/ParserSpec.hs
Outdated
let (parse', expectError) = helperFuncs $ P.imports [] | ||
it "can single import name w/o trailing comma" $ do | ||
parse' "import foo.bar (a);" `shouldBeRight` | ||
[ Import ["foo", "bar"] "a" "a" empty ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
test/Nirum/ParserSpec.hs
Outdated
parse' "import foo.bar (a,);" `shouldBeRight` | ||
[ Import ["foo", "bar"] "a" "a" empty ] | ||
parse' "import foo.bar (a as qux,);" `shouldBeRight` | ||
[ Import ["foo", "bar"] "qux" "a" empty ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
src/Nirum/Parser.hs
Outdated
<?> "names to import" | ||
idents <- many' [] $ \ importNames' -> do | ||
notFollowedBy $ choice [char ')', char ',' >> spaces >> char ')'] | ||
let forwardNames' = [ i | (i, _, _) <- importNames' ] ++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
25da998
to
1a7da15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build is failing due to lint:
test/Nirum/TypeInstance/BoundModuleSpec.hs:56:1: too long line (83 chars)
test/Nirum/ParserSpec.hs:1180:1: too long line (81 chars)
test/Nirum/ParserSpec.hs:1185:1: too long line (81 chars)
test/Nirum/ParserSpec.hs:1206:1: too long line (82 chars)
test/Nirum/ParserSpec.hs:1215:1: too long line (83 chars)
test/Nirum/ParserSpec.hs:1255:1: too long line (91 chars)
1a7da15
to
6be588a
Compare
It's handy to avoid a name shadowing. It resolve #217.
However, it needs more test cases for merge.