Re: Incompatible types #<IntegerType int> and #<BooleanType boolean>.

31 views
Skip to first unread message

Nick Howard

unread,
Apr 5, 2013, 4:14:03 PM4/5/13
to mi...@googlegroups.com
I think this is an issue with Mirah's  error reporting. You can fix it by changing one of your usages of value to use a different name.

 Looking at the AST inspection, it looks like you have something like this in your code

loop do
  value = detector.readValue < 5
  LCD.drawString "#{value}        ", 0
end

And in the same scope, you assign 123 to value. This causes an error in type inference because the typer doesn't know whether the variable value is an int or a boolean.

The reason the message is so confusing is because Mirah's reported the drawLine error instead of the assignment error. 

I added an issue for the problem (https://github.com/mirah/mirah/issues/214). Thanks for reporting it. Let us know if you have any other issues.



On Fri, Apr 5, 2013 at 11:47 AM, Peter Ehrlich <peter.i...@gmail.com> wrote:
I've got this piece of code which won't compile:

value = 123
LCD.drawInt(123, 0, 6)
LCD.drawInt(value, 0, 7)

Fails:

> mirahc  --classpath  /Users/peter/Downloads/leJOS_NXJ_0.9.1beta-3/lib/nxt/classes.jar main.mirah 
Parsing...
  main.mirah
Inferring types...
Inference Error:
main.mirah:78: Incompatible types #<IntegerType int> and #<BooleanType boolean>.
    LCD.drawInt(value, 0, 6)
                ^^^^^


Questions:
 - ) What's this error mean? How can I fix it?
 - ) Is there any way I can an internal backtrace in this error?  For debugging, I was able to find the line in the Mirah gem which threw this error, but not what called that method.  --trace and --backtrace aren't recognized

Thanks!!!
--Peter

--
You received this message because you are subscribed to the Google Groups "The Mirah Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirah+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
-Nick Howard
http://blog.baroquebobcat.com/

Reply all
Reply to author
Forward
0 new messages