* fixed nimsuggest crash with 'Something = concept' put (erroneously) outside of a 'type' block (#23331)

This commit is contained in:
Nikolay Nikolov
2024-02-24 08:55:23 +02:00
committed by GitHub
parent 6ce6cd4bb8
commit 37ed8c8480
3 changed files with 28 additions and 1 deletions

View File

@@ -1427,7 +1427,7 @@ proc parseTypeDesc(p: var Parser, fullExpr = false): PNode =
result = newNodeP(nkObjectTy, p)
getTok(p)
of tkConcept:
result = nil
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)

View 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
"""

View 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
"""