This commit is contained in:
Timothee Cour
2021-04-19 19:02:52 -07:00
committed by GitHub
parent 3b80f0dc8e
commit ad67bcf379
5 changed files with 9 additions and 16 deletions

View File

@@ -112,7 +112,7 @@ proc getTokenLenFromSource(conf: ConfigRef; ident: string; info: TLineInfo): int
if ident[^1] == '=' and ident[0] in linter.Letters:
if sourceIdent != "=":
result = 0
elif sourceIdent.len > ident.len and sourceIdent[..ident.high] == ident:
elif sourceIdent.len > ident.len and sourceIdent[0..ident.high] == ident:
result = ident.len
elif sourceIdent != ident:
result = 0

View File

@@ -510,14 +510,6 @@ proc `..`*[T, U](a: sink T, b: sink U): HSlice[T, U] {.noSideEffect, inline, mag
## echo a[2 .. 3] # @[30, 40]
result = HSlice[T, U](a: a, b: b)
proc `..`*[T](b: sink T): HSlice[int, T] {.noSideEffect, inline, magic: "DotDot".} =
## Unary `slice`:idx: operator that constructs an interval `[default(int), b]`.
##
## .. code-block:: Nim
## let a = [10, 20, 30, 40, 50]
## echo a[.. 2] # @[10, 20, 30]
result = HSlice[int, T](a: 0, b: b)
when defined(hotCodeReloading):
{.pragma: hcrInline, inline.}
else:

View File

@@ -339,7 +339,7 @@ proc findMainFile(dir: string): string =
var nimFiles = 0
for kind, file in os.walkDir(dir):
if kind == pcFile:
if file.endsWith(cfgExt): return file[ .. ^(cfgExt.len+1)] & ".nim"
if file.endsWith(cfgExt): return file[0..^(cfgExt.len+1)] & ".nim"
elif file.endsWith(".nim"):
if result.len == 0: result = file
inc nimFiles

View File

@@ -171,7 +171,7 @@ block tableconstr:
# NEW:
doAssert 56 in 50..100
doAssert 56 in ..60
doAssert 56 in 0..60
block ttables2:

View File

@@ -11,10 +11,9 @@ verichtetd
# Test the new slices.
import strutils
var mystr = "Abgrund"
mystr[..1] = "Zu"
# mystr[..1] = "Zu" # deprecated
mystr[0..1] = "Zu"
mystr[4..4] = "5"
@@ -23,7 +22,8 @@ type
var myarr: array[TEnum, int] = [1, 2, 3, 4, 5, 6]
myarr[e1..e3] = myarr[e4..e6]
myarr[..e3] = myarr[e4..e6]
# myarr[..e3] = myarr[e4..e6] # deprecated
myarr[0..e3] = myarr[e4..e6]
for x in items(myarr): stdout.write(x)
echo()
@@ -46,7 +46,8 @@ echo mystr
mystr[4..4] = "u"
# test full replacement
mystr[.. ^2] = "egerichtet"
# mystr[.. ^2] = "egerichtet" # deprecated
mystr[0 .. ^2] = "egerichtet"
echo mystr