Enable allTypes() for argument definitions in functions
This commit is contained in:
@@ -61,10 +61,10 @@ class ArgumentDefinitionNode(ExpressionNode):
|
||||
return node
|
||||
|
||||
return Parser.allOf(
|
||||
Parser.oneOf(
|
||||
Parser.optional(Parser.oneOf(
|
||||
TypeNode.parse,
|
||||
TypeSpecifier.parse
|
||||
),
|
||||
)),
|
||||
Parser.doAssert(IdentifierNode.identifierParser(), "variable name"),
|
||||
Parser.optional(Parser.terminalParser(TokenType.DOTS, lambda val, pos: VarargNode(pos))),
|
||||
createNode=createNode
|
||||
|
||||
@@ -10,7 +10,7 @@ from smnp.runtime.tools import updatePos
|
||||
from smnp.type.model import Type
|
||||
from smnp.type.signature.matcher.list import listOfMatchers
|
||||
from smnp.type.signature.matcher.map import mapOfMatchers
|
||||
from smnp.type.signature.matcher.type import ofType, oneOf
|
||||
from smnp.type.signature.matcher.type import ofType, oneOf, allTypes
|
||||
|
||||
|
||||
class FunctionCallEvaluator(Evaluator):
|
||||
@@ -53,6 +53,13 @@ def argumentsNodeToMethodSignature(node):
|
||||
vararg = typeMatcher(child.type)
|
||||
else:
|
||||
sign.append(typeMatcher(child.type))
|
||||
elif type(child.type) == NoneNode:
|
||||
if child.vararg:
|
||||
if i != argumentsCount-1:
|
||||
raise RuntimeException("Vararg must be the last argument in signature", child.pos)
|
||||
vararg = allTypes()
|
||||
else:
|
||||
sign.append(allTypes())
|
||||
else:
|
||||
if child.vararg:
|
||||
if i != argumentsCount-1:
|
||||
|
||||
@@ -4,7 +4,9 @@ from smnp.type.signature.matcher.model import Matcher
|
||||
|
||||
def allTypes():
|
||||
allowedTypes = [t for t in Type if t != Type.VOID]
|
||||
return ofTypes(*allowedTypes)
|
||||
matcher = ofTypes(*allowedTypes)
|
||||
matcher.string = "any"
|
||||
return matcher
|
||||
|
||||
|
||||
def ofTypes(*types):
|
||||
|
||||
Reference in New Issue
Block a user