mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
* [backport] fixed nimsuggest crash with 'Something = concept' put (erroneously) outside of a 'type' block (#23331) (#23346)
(cherry picked from commit 37ed8c8480)
This commit is contained in:
@@ -1430,6 +1430,7 @@ proc parseTypeDesc(p: var Parser, fullExpr = false): PNode =
|
||||
result = newNodeP(nkObjectTy, p)
|
||||
getTok(p)
|
||||
of tkConcept:
|
||||
result = p.emptyNode
|
||||
parMessage(p, "the 'concept' keyword is only valid in 'type' sections")
|
||||
of tkVar: result = parseTypeDescKAux(p, nkVarTy, pmTypeDesc)
|
||||
of tkOut: result = parseTypeDescKAux(p, nkOutTy, pmTypeDesc)
|
||||
|
||||
12
nimsuggest/tests/tconcept1.nim
Normal file
12
nimsuggest/tests/tconcept1.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
SomeNumber = concept
|
||||
|
||||
#[!]#
|
||||
discard """
|
||||
$nimsuggest --tester $file
|
||||
>chk $1
|
||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;">> (toplevel): import(dirty): tests/tconcept1.nim [Processing]";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;13;;"the \'concept\' keyword is only valid in \'type\' sections";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;13;;"invalid indentation";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;13;;"expression expected, but found \'keyword concept\'";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;0;;"\'SomeNumber\' cannot be assigned to";;0
|
||||
"""
|
||||
15
nimsuggest/tests/tconcept2.nim
Normal file
15
nimsuggest/tests/tconcept2.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
SomeNumber = concept a, type T
|
||||
a.int is int
|
||||
int.to(T) is type(a)
|
||||
|
||||
#[!]#
|
||||
discard """
|
||||
$nimsuggest --tester $file
|
||||
>chk $1
|
||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;">> (toplevel): import(dirty): tests/tconcept2.nim [Processing]";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;2;;"invalid indentation";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;15;;"the \'concept\' keyword is only valid in \'type\' sections";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;15;;"invalid indentation";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;15;;"expression expected, but found \'keyword concept\'";;0
|
||||
chk;;skUnknown;;;;Error;;$file;;1;;2;;"\'SomeNumber\' cannot be assigned to";;0
|
||||
"""
|
||||
Reference in New Issue
Block a user