Skip to content

Commit 3e411d8

Browse files
committed
Updated linter
Fixed a bug in the linter involving validation of array arguments and array parameters in function calls.
1 parent 30afc9a commit 3e411d8

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ Single file build system and a batch build variant.
168168
- SKSE mod event names
169169

170170
## **Changelog**
171+
Version 1.0.2 - 2016/03/05:
172+
- Fixed a bug in the linter involving validation of array arguments and array parameters in function calls.
173+
171174
Version 1.0.1 - 2016/03/05:
172175
- Implemented support in the linter for Find and RFind functions for arrays.
173176
- Implemented support in the linter for documentation strings for functions and events with the Native keyword.

Source/Modules/Skyrim/Linter.py

+21-6
Original file line numberDiff line numberDiff line change
@@ -2099,8 +2099,13 @@ def NodeVisitor(self, node, expected = None):
20992099
self.Abort("Arguments are being passed out of order, but at least one argument does not specify which parameter it is passing a value to.")
21002100
if args[i].name.value.upper() == params[0].name:
21012101
argExpr = self.NodeVisitor(args[0].expression)
2102-
if argExpr != params[0].type and not self.CanAutoCast(argExpr, params[0].type):
2103-
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, params[0].type, argExpr))
2102+
paramType = None
2103+
if params[0].array:
2104+
paramType = "%s[]" % params[0].type
2105+
else:
2106+
paramType = params[0].type
2107+
if argExpr != paramType and not self.CanAutoCast(argExpr, paramType):
2108+
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, paramType, argExpr))
21042109
args.pop(i)
21052110
break
21062111
i += 1
@@ -2110,14 +2115,24 @@ def NodeVisitor(self, node, expected = None):
21102115
if params[0].expression:
21112116
if len(args) > 0:
21122117
argExpr = self.NodeVisitor(args[0].expression)
2113-
if argExpr != params[0].type and not self.CanAutoCast(argExpr, params[0].type):
2114-
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, params[0].type, argExpr))
2118+
paramType = None
2119+
if params[0].array:
2120+
paramType = "%s[]" % params[0].type
2121+
else:
2122+
paramType = params[0].type
2123+
if argExpr != paramType and not self.CanAutoCast(argExpr, paramType):
2124+
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, paramType, argExpr))
21152125
args.pop(0)
21162126
else:
21172127
if len(args) > 0:
21182128
argExpr = self.NodeVisitor(args[0].expression)
2119-
if argExpr != params[0].type and not self.CanAutoCast(argExpr, params[0].type):
2120-
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, params[0].type, argExpr))
2129+
paramType = None
2130+
if params[0].array:
2131+
paramType = "%s[]" % params[0].type
2132+
else:
2133+
paramType = params[0].type
2134+
if argExpr != paramType and not self.CanAutoCast(argExpr, paramType):
2135+
self.Abort("Parameter %s is of type %s, but the argument evaluates to %s, which cannot be auto-cast to the parameter's type." % (params[0].name, paramType, argExpr))
21212136
args.pop(0)
21222137
else:
21232138
self.Abort("Mandatory parameter %s was not given an argument." % params[0].name)

0 commit comments

Comments
 (0)