Deprecate the dot style for import paths (#8474)

This commit is contained in:
Oscar Nihlgård
2018-07-30 15:24:16 +02:00
committed by Varriount
parent 52807287a4
commit 5491f1f53b
3 changed files with 15 additions and 11 deletions

View File

@@ -22,6 +22,8 @@
become an error in the future.
- The ``'c`` and ``'C'`` prefix for octal literals is now deprecated to
bring the language in line with the standard library (e.g. ``parseOct``).
- The dot style for import paths (e.g ``import path.to.module`` instead of
``import path/to/module``) has been deprecated.
#### Breaking changes in the standard library

View File

@@ -155,6 +155,7 @@ proc getModuleName*(conf: ConfigRef; n: PNode): string =
# hacky way to implement 'x / y /../ z':
result = renderTree(n, {renderNoComments}).replace(" ")
of nkDotExpr:
localError(conf, n.info, warnDeprecated, "using '.' instead of '/' in import paths")
result = renderTree(n, {renderNoComments}).replace(".", "/")
of nkImportAs:
result = getModuleName(conf, n.sons[0])

View File

@@ -6229,10 +6229,10 @@ imported:
:test: "nim c $1"
:status: 1
import strutils except `%`, toUpper
import strutils except `%`, toUpperAscii
# doesn't work then:
echo "$1" % "abc".toUpper
echo "$1" % "abc".toUpperAscii
It is not checked that the ``except`` list is really exported from the module.
@@ -6261,24 +6261,24 @@ A module alias can be introduced via the ``as`` keyword:
echo su.format("$1", "lalelu")
The original module name is then not accessible. The
notations ``path/to/module`` or ``path.to.module`` or ``"path/to/module"``
can be used to refer to a module in subdirectories:
The original module name is then not accessible. The notations
``path/to/module`` or ``"path/to/module"`` can be used to refer to a module
in subdirectories:
.. code-block:: nim
import lib.pure.strutils, lib/pure/os, "lib/pure/times"
import lib/pure/os, "lib/pure/times"
Note that the module name is still ``strutils`` and not ``lib.pure.strutils``
Note that the module name is still ``strutils`` and not ``lib/pure/strutils``
and so one **cannot** do:
.. code-block:: nim
import lib.pure.strutils
echo lib.pure.strutils
import lib/pure/strutils
echo lib/pure/strutils.toUpperAscii("abc")
Likewise the following does not make sense as the name is ``strutils`` already:
.. code-block:: nim
import lib.pure.strutils as strutils
import lib/pure/strutils as strutils
Collective imports from a directory
@@ -6297,7 +6297,8 @@ name is not a valid Nim identifier it needs to be a string literal:
Pseudo import/include paths
~~~~~~~~~~~~~~~~~~~~~~~~~~~
A directory can also be a so called "pseudo directory".
A directory can also be a so called "pseudo directory". They can be used to
avoid ambiguity when there are multiple modules with the same path.
There are two pseudo directories: