Page 1 of 1

-compile-if-needed take into account a different -number?

PostPosted: Sun Jul 04, 2010 8:16 am
by nevdelap
Hey.

Just want to get your opinion before I add something to trac.

Code: Select all
class Program
   def main
      assert 3.0.getType.toString == "System.Single"


If I was to compile this for the first time with -number:float32 it would work, correctly.
If I compile it again with -number:float64 it wouldn't work, correctly.
But if on the second compile I'd had -compile-if-needed it would have continued working, incorrectly.

I'm thinking that what's defined as 'if needed' might need to include if the already compiled program was compiled with a different -number setting than what's being attempted. I have no idea so far what that would entail in the compiler, and it's probably pretty edge case, but it could confuse someone at some point when it's in something non-trivial.

Code: Select all
nev@bananinha:~/Temp/cobra$ cobra -number:float32 test2.cobra
nev@bananinha:~/Temp/cobra$ cobra -number:float64 test2.cobra
An unhandled exception has occurred.
<snip>
Unhandled Exception: Cobra.Lang.AssertException: (Good)
<snip>
nev@bananinha:~/Temp/cobra$ cobra -number:float32 test2.cobra
nev@bananinha:~/Temp/cobra$ cobra -compile-if-needed -number:float64 test2.cobra
nev@bananinha:~/Temp/cobra$ (Oops!)

Re: -compile-if-needed take into account a different -number

PostPosted: Sun Jul 04, 2010 9:46 am
by Charles
Other flags that could change results are -contracts -include-asserts -include-tests -include-nil-checks -include-traces -native-compiler -native-compiler-args (maybe) -ref -main

Not sure where to put that info though. I think we either come up with a solution that captures the flags somehow, or we simply document this shortcoming of -compile-if-needed.

Re: -compile-if-needed take into account a different -number

PostPosted: Mon Jul 05, 2010 3:21 am
by hopscc
We discussed this around time of compile-if-needed implementation.
A solution mooted was to place some metainfo in the exe describing the compilation flags and check for flags change if -cif specified.
The situation was left as describing -cif as purely a timestamp based comparison which was all it was implemented as....

Re: -compile-if-needed take into account a different -number

PostPosted: Mon Jul 05, 2010 3:01 pm
by nevdelap
I suspected it was along those lines. I agree, best just highlighted in doco.