bcc icon indicating copy to clipboard operation
bcc copied to clipboard

Function/Method references wrongly interpreted as calls

Open HurryStarfish opened this issue 5 years ago • 2 comments

Bug Report

SuperStrict
Framework BRL.StandardIO

Type T
	Method M:Int() Return 1 End Method
	Function F:Int() Return 2 End Function
End Type

Function Test:Int()
	Local o:T = New T
	'Return T.F     ' "Unable to convert from Int() to Int"
	'Return T.M     ' "Internal Error in TCTranslator.TransFunc"
	'Return o.F     ' "Unable to convert from Int() to Int"
	'Return o.M     ' compiles and runs
	'Return New T.M ' compiles and runs
	'Return New T.F ' compiles and runs
End Function

Print Test()

Expected Behavior

Any of the above Return statements, when uncommented, should result in a compile error, since function/method names not followed by parentheses may only be interpreted as calls when they are statements, not when they are expressions. This should be "Unable to convert from Int() to Int" for the lines including .F; possibly a different message for the lines including .M, as it is not currently allowed to treat a method as a value (or, in the case of Return T.M, to reference it from its type name instead of an object).

Actual Behavior

see the code comments

HurryStarfish avatar May 15 '19 16:05 HurryStarfish