v45 - Strict Missing return statement for Abstract

Monkey Forums/Monkey Programming/v45 - Strict Missing return statement for Abstract

therevills(Posted 2011) [#1]
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".


marksibly(Posted 2011) [#2]
Hi,

D'oh! Just uploaded V45b...


therevills(Posted 2011) [#3]
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).


marksibly(Posted 2011) [#4]
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.


Rixarn(Posted 2011) [#5]
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


marksibly(Posted 2011) [#6]
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 []'