mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
* fix issue #20922 by handling missing expr in `exprList` for `tkOf`
* fix line numbers in test case
* rewrite exprList requiring expr, add optionalExprList for except
As suggested by @metagn.
* update test case to reflect new code
* update grammar.txt
* update line numbers in test case taking into account nimout
Given the number of errors that are produced it seems easier to do it
this way instead of using `tt.Error`.
(cherry picked from commit 0a1d4ba842)
47 lines
1.8 KiB
Nim
47 lines
1.8 KiB
Nim
discard """
|
|
cmd: "nim check $options --verbosity:0 $file"
|
|
action: "reject"
|
|
nimout: '''
|
|
t20922.nim(37, 5) Error: expression expected, but found ':'
|
|
Error: in expression ' '+'': identifier expected, but found ''
|
|
t20922.nim(37, 7) Error: attempting to call undeclared routine: '<Error>'
|
|
Error: in expression ' '+'': identifier expected, but found ''
|
|
t20922.nim(37, 7) Error: attempting to call undeclared routine: '<Error>'
|
|
t20922.nim(37, 7) Error: expression '' cannot be called
|
|
t20922.nim(37, 7) Error: expression '' has no type (or is ambiguous)
|
|
t20922.nim(37, 7) Error: VM problem: dest register is not set
|
|
t20922.nim(45, 7) Error: expression expected, but found ':'
|
|
t20922.nim(46, 5) Error: ':' or '=' expected, but got 'keyword of'
|
|
t20922.nim(45, 9) Error: undeclared identifier: 'x'
|
|
t20922.nim(45, 9) Error: expression 'x' has no type (or is ambiguous)
|
|
Error: in expression ' x': identifier expected, but found ''
|
|
t20922.nim(45, 9) Error: attempting to call undeclared routine: '<Error>'
|
|
Error: in expression ' x': identifier expected, but found ''
|
|
t20922.nim(45, 9) Error: attempting to call undeclared routine: '<Error>'
|
|
t20922.nim(45, 9) Error: expression '' cannot be called
|
|
t20922.nim(45, 9) Error: expression '' has no type (or is ambiguous)
|
|
t20922.nim(45, 9) Error: VM problem: dest register is not set
|
|
t20922.nim(33, 6) Hint: 'mapInstrToToken' is declared but not used [XDeclaredButNotUsed]
|
|
t20922.nim(43, 3) Hint: 'Foo' is declared but not used [XDeclaredButNotUsed]
|
|
'''
|
|
"""
|
|
# original test case issue #20922
|
|
type Token = enum
|
|
incDataPtr,
|
|
incDataPtrByte
|
|
|
|
proc mapInstrToToken(instr: char): Token =
|
|
case instr:
|
|
of '>':
|
|
incDataPtr
|
|
of: '+':
|
|
incDataPtrByte
|
|
|
|
# same issue with `of` in object branches (different parser procs calling `exprList`)
|
|
type
|
|
Bar = enum A, B
|
|
Foo = object
|
|
case kind: Bar
|
|
of: x: int
|
|
of B: y: float
|