#193 Type checking

sampo Wed 16 Apr 2008

Hi, since this is my first post let me say Fan definitely looks interesting and after a (admittedly superficial) look seems to have gotten quite a few design decisions right (IMHO of course :)

Anyway, after a little fooling I stumbled onto something I'd like to know if it's a bug or a feature. I wrote this naive fibonacci -function, don't ask why it's using Floats that's just a side-effect of me testing the type system:

static Float fib(Float x)
{
  if ( x < 2.0)
    return 1.0
  else
    return (fib(x - 1.0) + fib(x - 2.0))
}

The compiler correctly barfed whenever I tried to use non-float constants up there except with the comparison. x < 2 compiled just fine but died at run time. So, is this a bug or a feature? (I'd personally like the compiler to catch this)

  • Sampo

brian Wed 16 Apr 2008

Yeap that is a bug - looks like == and != does the check for comparable types, but not the < operator. Thanks for your feedback.

brian Thu 17 Apr 2008

Fixed for build 1.0.25

This method just needed to include those operators.

sampo Thu 17 Apr 2008

Thanks for a quick answer and fix. The source code looked interesting and hackable as well.. maybe I'll muck around with it sometime =)

Login or Signup to reply.