v45 - Strict Missing return statement for Abstract
Monkey Forums/Monkey Programming/v45 - Strict Missing return statement for Abstract
| ||
Strict Function Main:Int() Local test:Test = new Test() test.a() Return 0 End Class AbTest Abstract Method a:Int() Abstract End Class Test Extends AbTest Method a:Int() Return 1 End End This code throws "Missing return statement". |
| ||
Hi, D'oh! Just uploaded V45b... |
| ||
Thanks for the quick fix Mark :) I notice that the exes have been updated but not the source files (I guess Im looking in decl.monkey). |
| ||
Hi, Ok, turns out this quick fix borks a few other things in Java/C# - fix in haste, repent at leisure! I'm going through strict mode pretty thoroughly right now (my bad - I never use it so it tends to get ignored) adding smarter code reachability detection and just generally cleaning up some bits that have grown a bit ugly over time. |
| ||
Hi Mark!, I'm getting a Cannot convert from {NULL} to Int[] error in this method. I don't if it's one of those borks you mention (tried in GLFW). Method getIntArray:Int[](name:String) if dataIntArray.Contains(name) = True Return dataIntArray.Get(name).i Else Error("Undefined variable "+name+" for IntArrayMap.") EndIf Return Null End method I think this should be allowed to Return Null |
| ||
Hi, Nope, that's correct. Arrays and strings in Monkey are NOT objects, therefore they cannot be Null. You can however return an empty array, ie: 'Return []' |