Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding an integer to a string: when is it checked? #289

Closed
meijeru opened this Issue · 4 comments

2 participants

@meijeru

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".

Moreover, "c" + 1 compiles happily, whereas print "c" + 1 will give:

*** Compiler Internal Error: Script Error : Invalid argument: none
*** Where: emit-integer-operation
*** Near:  [forall list [
expr: list/1
if block? unbox expr [comp-expression expr yes]
if object? expr [cast expr]
if type <> 'inline [
emitter/target/emit-argument expr functions/:name
]
]]
@meijeru

It does not make a difference!

@dockimbel
Owner

A few type checkings are obviously missing.

@dockimbel
Owner

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.

@dockimbel
Owner

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.

@dockimbel dockimbel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.