Wiki

Ticket #135 (new task)

Opened 9 years ago

misleading/non consistent warning message when assigning result of void returning method

Reported by: gauthier Owned by:
Priority: trivial Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

this program output different warnings if WillReturnVoid? is defined in another assembly:

class WillReturnVoid
	def returnVoid
		pass
		
class Program
	shared
		def main
			foo = WillReturnVoid()
			bar = foo.returnVoid
			print "void"

within assembly:

returnvoidvalueisnotassignable.cobra(9): error: There is no type for the left hand side of "=". Use a different method or change that method to return something.
returnvoidvalueisnotassignable.cobra(9): warning: The value of variable "bar" is never used.
Compilation failed - 1 error, 1 warning
Not running due to errors above.

another assembly:

returnvoidvalueisnotassignable.cobra(5): warning: The value of variable "bar" is never used.
c:\home\dev\tmp\cobratickets\returnvoid\returnvoidvalueisnotassignable.cobra(3): error: System.Void cannot be used from C# -- use typeof(void) to get the void type object.
c:\home\dev\tmp\cobratickets\returnvoid\returnvoidvalueisnotassignable.cobra(5): error: Cannot implicitly convert type "void" to "System.Void"
Compilation failed - 2 errors, 1 warning
Not running due to errors above.

expected result: one consistent message:

"you can't assign the result of [methodName] from [methodOwnerType] to [assigneeExpr] because this method is defined to return void"

Note: See TracTickets for help on using tickets.