Unused code check

Monkey Forums/Monkey Bug Reports/Unused code check

dragon(Posted 2013) [#1]
Monkey do not check "unused" code - even if you set strict mode

Strict
Import mojo

Global table:Int[100]

Class Program Extends App
	
	Method OnCreate:Int ()
		SetUpdateRate(60)
		Return 0
	End

	Method OnUpdate:Int ()
		Return 0
	End

	Method OnRender:Int ()
		Return 0
	End
End

Function dummy:Void () '<<<unused
	table(1) = 1 '<<<< this is wrong, but monkey think my code is ok
End

Function Main:Int ()
	New Program()
	Return 0
End


As you can see above code - i add a bug to a line,
but this code is not checked, because it is unused...

This can have side-effects, if you use that block of code later...


MikeHart(Posted 2013) [#2]
To workaround this feature, import reflection and set the reflection filter to you code. All this temporary. This way you catch errors in code you don't use. I am glad it does not check it by default cause i think it slows down the compiling process.