void func() now gives warning if func doesn't return a value

This commit is contained in:
Irmen de Jong 2022-11-22 22:54:40 +01:00
parent c21913a66b
commit 7ebcb219d6
2 changed files with 18 additions and 1 deletions

View File

@ -1028,6 +1028,23 @@ internal class AstChecker(private val program: Program,
if(targetStatement!=null) {
checkFunctionCall(targetStatement, functionCallStatement.args, functionCallStatement.position)
checkUnusedReturnValues(functionCallStatement, targetStatement, errors)
if(functionCallStatement.void) {
when(targetStatement) {
is BuiltinFunctionPlaceholder -> {
if(!builtinFunctionReturnType(targetStatement.name).isKnown)
errors.warn("redundant void", functionCallStatement.position)
}
is Label -> {
errors.warn("redundant void", functionCallStatement.position)
}
is Subroutine -> {
if(targetStatement.returntypes.isEmpty())
errors.warn("redundant void", functionCallStatement.position)
}
else -> {}
}
}
}
val funcName = functionCallStatement.target.nameInSource

View File

@ -328,7 +328,7 @@ internal class StatementReorderer(val program: Program,
assign.value as? IdentifierReference ?: assign.value,
identifier
),
true,
false,
assign.position
)
return listOf(IAstModification.ReplaceNode(assign, strcopy, assign.parent))