mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
error message for invalid operand types for logical or bitwise operators
This commit is contained in:
parent
255c808b16
commit
8e36a64d49
@ -65,4 +65,4 @@ task fatJar(type: Jar) {
|
||||
from { project.configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
with jar
|
||||
}
|
||||
build.finalizedBy(fatJar)
|
||||
// build.finalizedBy(fatJar)
|
@ -694,6 +694,13 @@ private class AstChecker(private val namespace: INameScope,
|
||||
checkResult.add(ExpressionError("remainder can only be used on unsigned integer operands", expr.right.position))
|
||||
}
|
||||
}
|
||||
"and", "or", "xor", "&", "|", "^" -> {
|
||||
// only integer numeric operands accepted
|
||||
val rightDt = expr.right?.resultingDatatype(namespace, heap)
|
||||
val leftDt = expr.left.resultingDatatype(namespace, heap)
|
||||
if(leftDt !in IntegerDatatypes || rightDt !in IntegerDatatypes)
|
||||
checkResult.add(ExpressionError("logical or bitwise operator can only be used on integer operands", expr.right.position))
|
||||
}
|
||||
}
|
||||
|
||||
val leftDt = expr.left.resultingDatatype(namespace, heap)!!
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from prog8.g4 by ANTLR 4.7.2
|
||||
// Generated from ./parser/antlr/prog8.g4 by ANTLR 4.7.2
|
||||
|
||||
package prog8.parser;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from prog8.g4 by ANTLR 4.7.2
|
||||
// Generated from ./parser/antlr/prog8.g4 by ANTLR 4.7.2
|
||||
|
||||
package prog8.parser;
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="prog8" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Python" name="Python">
|
||||
<configuration sdkName="Python 3.7" />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
Loading…
Reference in New Issue
Block a user