scratch-ed / scratch-LN

https://scratch4d.github.io/scratch-LN/
Apache License 2.0
21 stars 9 forks source link

generate errors/warnings in visitor #61

Open pdawyndt opened 6 years ago

pdawyndt commented 6 years ago
Ellen102 commented 6 years ago
Ellen102 commented 6 years ago
Ellen102 commented 6 years ago
Ellen102 commented 6 years ago
pdawyndt commented 6 years ago
Ellen102 commented 6 years ago

Currently:

Ellen102 commented 6 years ago

note for generating warnings when the wrong inputtype is used:

Ellen102 commented 6 years ago

should say {1} generate a warning?

pdawyndt commented 6 years ago

I guess your idea was that say {1} can also be written as say "1" or as say {"1"} in line with the fact that Scratch does not make a difference between numbers and strings. In that respect, none of these alternatives should generate warnings.

Only if you can infer a difference between numbers and strings from the block context, I would generate warnings if a number is used where a string is expected or where a string is used where a number is expected. Together with the warnings, I would automatically cast the number into a string if a string is expected (this is always possible) and try to cast the string into a number if a number is expected (this is something that could fail; if it fails, I would issue an error instead of a warning if no sensible block conversion can be done).

Ellen102 commented 6 years ago

I agree. There are more input types then just numbers. I am working on this function to verify the value. (not yet fully tested)