mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
void func() now gives warning if func doesn't return a value
This commit is contained in:
parent
c21913a66b
commit
7ebcb219d6
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user