mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes a regression about static object case variant checking
This commit is contained in:
@@ -77,7 +77,9 @@ proc semConstrField(c: PContext, flags: TExprFlags,
|
||||
|
||||
proc caseBranchMatchesExpr(branch, matched: PNode): bool =
|
||||
for i in 0 .. branch.len-2:
|
||||
if exprStructuralEquivalent(branch[i], matched):
|
||||
if branch[i].kind == nkRange:
|
||||
if overlap(branch[i], matched): return true
|
||||
elif exprStructuralEquivalent(branch[i], matched):
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
@@ -49,4 +49,34 @@ var t = stack.pop()
|
||||
echo "came here"
|
||||
|
||||
|
||||
# another regression:
|
||||
type
|
||||
LexerToken* = enum
|
||||
ltYamlDirective, ltYamlVersion, ltTagDirective, ltTagShorthand,
|
||||
ltTagUri, ltUnknownDirective, ltUnknownDirectiveParams, ltEmptyLine,
|
||||
ltDirectivesEnd, ltDocumentEnd, ltStreamEnd, ltIndentation, ltQuotedScalar,
|
||||
ltScalarPart, ltBlockScalarHeader, ltBlockScalar, ltSeqItemInd, ltMapKeyInd,
|
||||
ltMapValInd, ltBraceOpen, ltBraceClose, ltBracketOpen, ltBracketClose,
|
||||
ltComma, ltLiteralTag, ltTagHandle, ltAnchor, ltAlias
|
||||
|
||||
const tokensWithValue =
|
||||
{ltScalarPart, ltQuotedScalar, ltYamlVersion, ltTagShorthand, ltTagUri,
|
||||
ltUnknownDirective, ltUnknownDirectiveParams, ltLiteralTag, ltAnchor,
|
||||
ltAlias, ltBlockScalar}
|
||||
|
||||
type
|
||||
TokenWithValue = object
|
||||
case kind: LexerToken
|
||||
of tokensWithValue:
|
||||
value: string
|
||||
of ltIndentation:
|
||||
indentation: int
|
||||
of ltTagHandle:
|
||||
handle, suffix: string
|
||||
else: discard
|
||||
|
||||
proc sp(v: string): TokenWithValue =
|
||||
# test.nim(27, 17) Error: a case selecting discriminator 'kind' with value 'ltScalarPart' appears in the object construction, but the field(s) 'value' are in conflict with this value.
|
||||
TokenWithValue(kind: ltScalarPart, value: v)
|
||||
|
||||
let a = sp("test")
|
||||
|
||||
Reference in New Issue
Block a user