When provoking the previous issue, I noticed that 1 + "c" will compile without protest, but print 1 + "c" will give an math-code error, as will the assignment a: 1 + "c".
1 + "c"
print 1 + "c"
a: 1 + "c"
Moreover, "c" + 1 compiles happily, whereas print "c" + 1 will give:
"c" + 1
print "c" + 1
*** Compiler Internal Error: Script Error : Invalid argument: none
*** Where: emit-integer-operation
*** Near: [forall list [
if block? unbox expr [comp-expression expr yes]
if object? expr [cast expr]
if type <> 'inline [
emitter/target/emit-argument expr functions/:name
It does not make a difference!
A few type checkings are obviously missing.
It is a side-effect of pointer arithmetics. No distinction is made between a literal string and non-literal one. I need to add some checking to raise a compilation error.
1 + "c" (or reversed expression) will compile silently because this expression will be caught by the dead code detection routine (added 2-3 months ago) and will not generate any native code. As the functions arguments type checking appends later in the compilation process, no error is raised.
FIX: issue #289 (Adding an integer to a string: when is it checked?)