Error using Linq method

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Bernhard Mayer
Posts: 52
Joined: Thu Oct 06, 2016 3:00 pm
Location: Austria

Error using Linq method

Post by Bernhard Mayer »

Dear fellow X#'ers!

I just installed the latest FOX Bandol 2.0.1 version and did my usual initial test: Clean + Build the solution. The compiler now throws an error for a piece of code which has never been a problem before:

Code: Select all

 LOCAL languages AS IEnumerable<STRING>
languages := langIni:GetSection("POOL")
IF languages:ANY() // XS9002 Parser: unexpected input 'IF languages:ANY'
   result := languages:First()
ENDIF 
The proper using directives System.Collections.Generic and System.Linq are included in the source code file, so is the assembly reference System.Core. Changing the character casing of "ANY" to "Any" does not seem to make a difference either.

Any idea what I'm doing wrong?

Best regards,
Bernhard
Using VS 2017 Enterprise 15.9.4 with the Vulcan.NET dialect.
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Error using Linq method

Post by lumberjack »

Hi Bernhard,
Bernhard Mayer wrote:Dear fellow X#'ers!
I just installed the latest FOX Bandol 2.0.1 version and did my usual initial test: Clean + Build the solution. The compiler now throws an error for a piece of code which has never been a problem before:

Code: Select all

 LOCAL languages AS IEnumerable<STRING>
languages := langIni:GetSection("POOL")
IF languages:@@ANY() // XS9002 Parser: unexpected input 'IF languages:ANY'
   result := languages:First()
ENDIF 
Any idea what I'm doing wrong?
Change to @@Any do the trick. It seems Vulcan dialect have "ANY" as a keyword. If you run the code under Core it will run unchanged.

Code: Select all

USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text

FUNCTION Start() AS VOID
	LOCAL languages AS IEnumerable<STRING>
	languages := List<STRING>{<STRING>{"Lang1", "Lang2", "Lang3"}}
	LOCAL result AS LOGIC
	IF result := languages:Any() // No problem with Core
	ENDIF
	?result
RETURN
______________________
Johan Nel
Boshof, South Africa
Bernhard Mayer
Posts: 52
Joined: Thu Oct 06, 2016 3:00 pm
Location: Austria

Error using Linq method

Post by Bernhard Mayer »

Thanks, it's working this way.
BR,
Bernhard
Post Reply