mirror of
https://github.com/irmen/prog8.git
synced 2024-09-09 02:54:28 +00:00
fix compiler crash when trying to concatenate string var and string literal.
This commit is contained in:
parent
5df623bd2e
commit
b21f7411dd
@ -862,6 +862,14 @@ internal class AstChecker(private val program: Program,
|
|||||||
errors.err("right operand is not numeric or str", expr.right.position)
|
errors.err("right operand is not numeric or str", expr.right.position)
|
||||||
if(leftDt!=rightDt)
|
if(leftDt!=rightDt)
|
||||||
errors.err("left and right operands aren't the same type", expr.left.position)
|
errors.err("left and right operands aren't the same type", expr.left.position)
|
||||||
|
|
||||||
|
if(expr.operator !in comparisonOperators) {
|
||||||
|
if (leftDt == DataType.STR && rightDt == DataType.STR || leftDt in ArrayDatatypes && rightDt in ArrayDatatypes) {
|
||||||
|
// str+str and str*number have already been const evaluated before we get here.
|
||||||
|
errors.err("no computational expressions with strings or arrays are possible", expr.position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visit(typecast: TypecastExpression) {
|
override fun visit(typecast: TypecastExpression) {
|
||||||
|
@ -9,7 +9,7 @@ import prog8.ast.walk.IAstVisitor
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.round
|
import kotlin.math.round
|
||||||
|
|
||||||
|
// TODO capitalize for consistency
|
||||||
val associativeOperators = setOf("+", "*", "&", "|", "^", "or", "and", "xor", "==", "!=")
|
val associativeOperators = setOf("+", "*", "&", "|", "^", "or", "and", "xor", "==", "!=")
|
||||||
val comparisonOperators = setOf("==", "!=", "<", ">", "<=", ">=")
|
val comparisonOperators = setOf("==", "!=", "<", ">", "<=", ">=")
|
||||||
val augmentAssignmentOperators = setOf("+", "-", "/", "*", "**", "&", "|", "^", "<<", ">>", "%", "and", "or", "xor")
|
val augmentAssignmentOperators = setOf("+", "-", "/", "*", "**", "&", "|", "^", "<<", ">>", "%", "and", "or", "xor")
|
||||||
|
@ -313,10 +313,12 @@ platform (if defined). For the C-64, that is SCREEN CODES (also known as POKE co
|
|||||||
This @-prefix can also be used for character byte values.
|
This @-prefix can also be used for character byte values.
|
||||||
|
|
||||||
|
|
||||||
You can concatenate two string literals using '+' (not very useful though) or repeat
|
You can concatenate two string literals using '+', which can be useful to
|
||||||
a string literal a given number of times using '*'. You can also assign a new string
|
split long strings over separate lines. But remember that the length
|
||||||
value to another string. No bounds check is done so be sure the destination string is
|
of the total string still cannot exceed 255 characaters.
|
||||||
large enough to contain the new value (it is overwritten in memory)::
|
A string literal can also be repeated a given number of times using '*'.
|
||||||
|
And a new string value can be assigned to another string, but no bounds check is done
|
||||||
|
so be sure the destination string is large enough to contain the new value (it is overwritten in memory)::
|
||||||
|
|
||||||
str string1 = "first part" + "second part"
|
str string1 = "first part" + "second part"
|
||||||
str string2 = "hello!" * 10
|
str string2 = "hello!" * 10
|
||||||
@ -330,9 +332,6 @@ as newlines, quote characters themselves, and so on. The ones used most often ar
|
|||||||
``\\``, ``\"``, ``\n``, ``\r``. For a detailed description of all of them and what they mean,
|
``\\``, ``\"``, ``\n``, ``\r``. For a detailed description of all of them and what they mean,
|
||||||
read the syntax reference on strings.
|
read the syntax reference on strings.
|
||||||
|
|
||||||
You can use the automatic string concatenation using ``+`` to split long strings over separate
|
|
||||||
lines, but remember that the length of the total string still cannot exceed 255 characaters.
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
Strings/arrays and uwords (=memory address) can often be interchanged.
|
Strings/arrays and uwords (=memory address) can often be interchanged.
|
||||||
An array of strings is actually an array of uwords where every element is the memory
|
An array of strings is actually an array of uwords where every element is the memory
|
||||||
|
@ -3,8 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next compiler release (7.6)
|
For next compiler release (7.6)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
fix compiler crash when trying to concatenate string var and string literal.
|
|
||||||
|
|
||||||
fix return value of diskio.load() (see commment) and possibly other routines?
|
fix return value of diskio.load() (see commment) and possibly other routines?
|
||||||
|
|
||||||
optimization in call convention:
|
optimization in call convention:
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte @shared yy
|
str derp = "derp" * 4
|
||||||
|
derp = derp / "zzz"
|
||||||
if yy&64 {
|
derp = derp - "zzz"
|
||||||
yy++
|
derp = derp + "zzz"
|
||||||
}
|
txt.print(&derp+2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user