Compatibility with VO: function or method

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
wriedmann
Posts: 3668
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Compatibility with VO: function or method

Post by wriedmann »

Hello,

porting one of my libraries I have come around a IMHO serious issue.
Please see the following code:

Code: Select all

using System

function Start( ) as void
	Console.WriteLine("Hello x#!")    
	MyClass{}:MyFunc()
	return
	
function MyFunc() as string
	
	return "from static class"

class MyClass
	
method MyFunc() as string
	
	MyFunc()
	
	return MyFunc()
	
end class
If you execute this code in VO, it works as expected.
In X# it throws an stack overflow error, because the "MyFunc()" call in the method calls itself, and not the defined function.
IMHO there should be a compiler option that requires that all method calls are prefixed with self:, otherwise they should not refer to the method of the class, but search outside of the class.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4599
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Compatibility with VO: function or method

Post by Chris »

Hi Wolfgang,

Hmm, right, in VO dialect (and vulcan etc) this works as expected, but in Core it calls the method instead of the function indeed. Thanks for reporting, will log this as well.

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply