forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treat resolved symbols on RHS of module qualification as identifiers
fixes nim-lang#19866 given nim-lang#23997
- Loading branch information
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type A* = object | ||
x*: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type A* = object | ||
x*: array[1000, byte] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# issue #19866 | ||
|
||
# Switch module import order to switch which of last two | ||
# doAsserts fails | ||
import mqualifiedtype1 | ||
import mqualifiedtype2 | ||
|
||
# this isn't officially supported but needed to point out the issue: | ||
template f(moduleName: untyped): int = sizeof(`moduleName`.A) | ||
template g(someType: untyped): int = sizeof(someType) | ||
|
||
# These are legitimately true. | ||
doAssert sizeof(mqualifiedtype1.A) != sizeof(mqualifiedtype2.A) | ||
doAssert g(mqualifiedtype1.A) != g(mqualifiedtype2.A) | ||
|
||
# Which means that this should not be true, but is in Nim 1.6 | ||
doAssert f(`mqualifiedtype1`) != f(`mqualifiedtype2`) | ||
doAssert f(mqualifiedtype1) != f(mqualifiedtype2) | ||
|
||
# These should be true, but depending on import order, exactly one | ||
# fails in Nim 1.2, 1.6 and devel. | ||
doAssert f(`mqualifiedtype1`) == g(mqualifiedtype1.A) | ||
doAssert f(`mqualifiedtype2`) == g(mqualifiedtype2.A) | ||
doAssert f(mqualifiedtype1) == g(mqualifiedtype1.A) | ||
doAssert f(mqualifiedtype2) == g(mqualifiedtype2.A) |