fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Optional parameter not recognized

Optional parameter not recognized 9 months 2 weeks ago #5970

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
Hi,

maybe I have found a problem with optional parameters.
Consider a class in a Vulcan.NET library with one constructor with two optional parameters, one of the parameter default values is cast:
CLASS ClassWithCtor
	CONSTRUCTOR(name := NULL_STRING AS STRING, number := (INT)1 AS INT)
		RETURN		
END CLASS

Then code that calls that constructor with one one argument:
LOCAL test := ClassWithCtor{"fancy"} AS ClassWithCtor

If this line calling the constructor is in a Vulcan.NET library it compiles without errors. If it is in an X# library I get this error:
'InheritedXsharp.ClassWithCtor{ STRING }' : no constructor that accepts these argument types VulcanReferencingXsharp

I have attached a demo solution.

Mathias
Attachments:

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5971

  robert's Avatar robert Offline Posts: 969
Mathias,

Which version of the compiler ?

Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5973

  Otto's Avatar Otto Offline Posts: 141
Same problem for me. 2.0.0.4 , the latest build

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5974

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
2.0.0.2

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5975

  robert's Avatar robert Offline Posts: 969
Otto,

Which dialect ? (Default parameters are handled differently in the Core dialect then in VO/Vulcan).

Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5986

  Chris's Avatar Chris Offline Posts: 1137
Guys,

I am afraid I can't reproduce the problem. Matthias, do you mean that you get an error when trying to use the X# class from a vulcan library? Or from another X# library? In the solution you provided, I see the class and the code calling it defined in the same .prg file and it compiles ok here.

Can you please give some more info?

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5989

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
Hi Chris,

I placed two calls in the solution. The one you found works here, too. The second one is in the Vulcan-Project "VulcanReferencingXsharp", and this one gives the compiler error.

Do you not get that error when you compile the hole solution?

Mathias

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5990

  Otto's Avatar Otto Offline Posts: 141
Vulcan.NET
I'll also try to create an sample. Didn't work the first time...

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5993

  Chris's Avatar Chris Offline Posts: 1137
Hi Kromi,

Kromi wrote: Hi Chris,

I placed two calls in the solution. The one you found works here, too. The second one is in the Vulcan-Project "VulcanReferencingXsharp", and this one gives the compiler error.

Do you not get that error when you compile the hole solution?

Mathias


I do not have vulcan installed in VS, so I could not test this, but tried the same scenario in XIDE and it worked without errors. Maybe it has to do with compiler options, will try to replicate the same and try again.

But in any case, is this scenario important for you, to use a X# dll from a vulcan project?

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5995

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
Hi Chris,

the scenario is important for me because I'm evaluating the transition of a huge Vulcan.NET solution to X#. Since I get some errors from the X# compiler that I can't resolve yet (e. g. calls to CCALLNATIVE) in a base project, my plan was to reset this project back to Vulcan.NET in order to be able to evaluate other projects that depend on the base project.

Mathias

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5996

  robert's Avatar robert Offline Posts: 969
Mathias,
In which scenario do you need to use CCALLNATIVE ?
Technically we could implement that like PCALLNATIVE but it is usually not necessary because there are usually other ways to achieve the same result.

Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5997

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
Hi Robert,

we use this function for communicating with 3rd party components like card readers and an LDAP library.

To be honest, I have no idea if we can replace CCallNative where we use it.

Mathias

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #5998

  Otto's Avatar Otto Offline Posts: 141
OK. I have found MY error. :oops:

I had typed

METHOD Constructor( param1 as string, param2 := "" as string)

and the error message was on the call to a constructor with 1 parameter which resulted in the error "can't find constructor with 1 parameter".

I should have typed

Constructor( param1 as string, param2 := "" as string)

Sorry for the inconvenience.

Is it an option to create an warning on the use of the word Constructor if the word method preceeds it or something like that?

I wonder how many METHOD Constructors without parameters I have created... :oops:
edit: none B)

Please Log in or Create an account to join the conversation.

Last edit: by Otto.

Optional parameter not recognized 9 months 2 weeks ago #5999

  Chris's Avatar Chris Offline Posts: 1137
Hi Matthias,

Kromi wrote: Hi Chris,

the scenario is important for me because I'm evaluating the transition of a huge Vulcan.NET solution to X#. Since I get some errors from the X# compiler that I can't resolve yet (e. g. calls to CCALLNATIVE) in a base project, my plan was to reset this project back to Vulcan.NET in order to be able to evaluate other projects that depend on the base project.

Mathias


I think the error you are seeing when calling the x# library from vulcan is a kind of dll mismatch problem, probably vulcan in VS "sees" an older version of the X# dll. Please try a Clean Solution, then Rebuild All, I think it will compile fine now.

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6000

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
Chris,

Cleaning, deleting bin and obj directories and rebuilding did not help, the error is still there.

If I change the signature of the called constructor in a way that there's no cast any more, the compiler is happy. If I add the cast again, the error returns.

Mathias

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6002

  Chris's Avatar Chris Offline Posts: 1137
Hi Matthias,

Kromi wrote: Chris,
Cleaning, deleting bin and obj directories and rebuilding did not help, the error is still there.

If I change the signature of the called constructor in a way that there's no cast any more, the compiler is happy. If I add the cast again, the error returns.


Hmm, this is very strange, normally this should not be making any difference in this code, I just checked the generated IL with and without the cast and it is identical. Just now I realized you said you are using an older X# build, can you please try again with the newer?

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6003

  Kromi's Avatar Topic Author Kromi Offline Posts: 32
I think I'm using the newest one that is publicly available. But I'll try again as soon as 2.0.0.4 is available.

Mathias

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6004

  Chris's Avatar Chris Offline Posts: 1137

Kromi wrote: I think I'm using the newest one that is publicly available. But I'll try again as soon as 2.0.0.4 is available.

Mathias


OK, I will install the build you're using and test also with it and will tell you if this is what makes the difference.

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6005

  wriedmann's Avatar wriedmann Offline Posts: 1545
Hi Chris,

I was able to download the solution as I have both the latest Vulcan and X# 2.0.0.4 in my Visual Studio 2015: the error is present also in this version:
Severity	Code	Description	Project	File	Line	Suppression State
Error		'InheritedXsharp.ClassWithCtor{ STRING }' : no constructor that accepts these argument types	VulcanReferencingXsharp	C:\DevNET\temp\VulcanReferencingXsharp\MyClass.prg	16	

If I can do something to help please let me know.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Optional parameter not recognized 9 months 2 weeks ago #6017

  Chris's Avatar Chris Offline Posts: 1137
Thanks Wolfgang!

Guys, do you get a warning from MSBuild that there is a mismatch between the platform of the vulcan runtime dlls (x86) and the platform target of the X# app (AnyCPU)? This should be displayed, but for some reason it doesn't and this makes me believe something has gone off in the solution and it does not get fixed with a rebuild either, I could fix it only with a Clean. Wolfgang, please try deleting all .dll/.exe files from the solution, then select rebuild all, does it make any difference?

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2