-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d075bd5
commit bc67e51
Showing
13 changed files
with
165 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{.experimental: "allowPrivateImport".} | ||
import ./m2 | ||
import ./m3 {.privateImport.} as m3 | ||
from ./m3 as m3Bis import nil | ||
# export m3 | ||
doAssert car2 == 2 | ||
export car2 | ||
|
||
export m3Bis.car1 | ||
|
||
const foo0* = 2 | ||
const foo1 = bar1 | ||
|
||
const foo1Aux = 2 | ||
export foo1Aux | ||
|
||
doAssert not declared(bar2) | ||
doAssert not compiles(bar2) | ||
|
||
var foo2 = 2 | ||
let foo3 = 2 | ||
|
||
type Foo4 = enum | ||
kg1, kg2 | ||
|
||
type Foo5 = object | ||
z1: string | ||
z2: Foo4 | ||
z3: int | ||
|
||
proc `z3`*(a: Foo5): auto = | ||
a.z3 * 10 | ||
|
||
proc foo6(): auto = 2 | ||
proc foo6b*(): auto = 2 | ||
template foo7: untyped = 2 | ||
macro foo8(): untyped = discard | ||
template foo9(a: int): untyped = discard | ||
|
||
block: | ||
template foo10: untyped = 2 | ||
type Foo11 = enum | ||
kg1b, kg2b | ||
proc foo12(): auto = 2 | ||
|
||
proc initFoo5*(z3: int): Foo5 = Foo5(z3: z3) |
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 @@ | ||
const bar1* = 2 | ||
const bar2 = 2 |
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 @@ | ||
const car1* = 2 | ||
const car2 = 2 |
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,10 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 as m | ||
doAssert compiles(foo0) | ||
doAssert not compiles(foo1) | ||
doAssert foo6b() == 2 | ||
doAssert car2 == 2 | ||
|
||
var f = initFoo5(z3=3) | ||
doAssert f.z3 == 30 | ||
doAssert z3(f) == 30 |
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,22 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 {.privateImport.} as m | ||
doAssert foo1 == 2 | ||
doAssert m.foo1 == 2 | ||
|
||
doAssert m.car2 == 2 | ||
doAssert car2 == 2 | ||
doAssert m.foo1Aux == 2 | ||
doAssert m.car1 == 2 | ||
|
||
## field access | ||
var x = Foo5(z1: "foo", z2: m.kg1) | ||
doAssert x.z1 == "foo" | ||
|
||
var f0: Foo5 | ||
f0.z3 = 3 | ||
doAssert f0.z3 == 3 | ||
var f = initFoo5(z3=3) | ||
doAssert f.z3 == 3 | ||
doAssert z3(f) == 30 | ||
doAssert m.z3(f) == 30 | ||
doAssert not compiles(mt1.`z3`(f)) # z3 is an imported symbol |
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,31 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
from ./m1 {.privateImport.} as m import foo1 | ||
from ./m1 {.privateImport.} as m2 import foo7 | ||
doAssert foo1 == 2 | ||
doAssert m.foo1 == 2 | ||
doAssert m.foo2 == 2 | ||
doAssert compiles(foo1) | ||
doAssert compiles(m.foo2) | ||
doAssert not compiles(foo2) | ||
doAssert not compiles(car2) | ||
doAssert m.foo3 == 2 | ||
doAssert m.foo6() == 2 | ||
doAssert m.foo6b() == 2 | ||
doAssert foo7() == 2 | ||
doAssert m2.foo6b() == 2 | ||
doAssert not compiles(foo10()) | ||
doAssert compiles(m.Foo5) | ||
doAssert not compiles(m.Foo11) | ||
doAssert not compiles(m.kg1b) | ||
doAssert not compiles(m.foo12()) | ||
|
||
## field access | ||
var x = m.Foo5(z1: "foo", z2: m.kg1) | ||
doAssert x.z1 == "foo" | ||
|
||
var f0: m.Foo5 | ||
f0.z3 = 3 | ||
doAssert f0.z3 == 3 | ||
var f = m.initFoo5(z3=3) | ||
doAssert f.z3 == 3 | ||
doAssert m.z3(f) == 30 |
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,8 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 {.privateImport.} | ||
doAssert foo1 == 2 | ||
|
||
doAssert m1.foo1 == 2 | ||
|
||
doAssert not compiles(mt3.foo0) # foo0 is an imported symbol | ||
doAssert not compiles(mt3.foo1) # ditto |
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,5 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 {.privateImport.} except foo1 | ||
doAssert foo2 == 2 | ||
doAssert declared(foo2) | ||
doAssert not compiles(foo1) |
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,4 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
from ./m1 {.privateImport.} as m2 import nil | ||
doAssert not compiles(foo1) | ||
doAssert m2.foo1 == 2 |
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,10 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 {.privateImport.} as m2 except foo1 | ||
doAssert foo2 == 2 | ||
doAssert not compiles(foo1) | ||
doAssert m2.foo1 == 2 | ||
doAssert compiles(m2.foo1) | ||
|
||
from system {.privateImport.} as s import ThisIsSystem | ||
doAssert ThisIsSystem | ||
doAssert s.ThisIsSystem |
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,10 @@ | ||
{.push experimental: "allowPrivateImport".} | ||
import ./m1 {.privateImport.} as m2 | ||
doAssert compiles(foo1) | ||
doAssert compiles(m2.foo1) | ||
doAssert declared(foo1) | ||
doAssert declared(m2.foo0) # public: works fine | ||
|
||
doAssert m2.foo1 == 2 | ||
doAssert declared(m2.foo1) | ||
doAssert not declared(m2.nonexistant) |
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,14 @@ | ||
include ./m1 | ||
doAssert compiles(foo1) | ||
doAssert compiles(mt7.foo1) | ||
doAssert declared(foo1) | ||
doAssert declared(mt7.foo1) | ||
doAssert declared(mt7.foo0) | ||
|
||
var f0: Foo5 | ||
f0.z3 = 3 | ||
doAssert f0.z3 == 3 | ||
var f = initFoo5(z3=3) | ||
doAssert f.z3 == 3 | ||
doAssert mt7.z3(f) == 30 | ||
doAssert z3(f) == 30 |
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 @@ | ||
import "."/[mt0,mt1,mt2,mt3,mt4,mt4b,mt5,mt6,mt7] |