Skip to content

[X# 3] Bogus error when concatenating string in .Net 10 #1787

@cpyrgas

Description

@cpyrgas

Following produces an error in one of the lines concatenating strings, when compiling against .Net 10.
When compiling against .Net 4 or 5, there is no error

FUNCTION Start() AS VOID
		System.Console.WriteLine("Hello .Net 5 from X#!")
		System.Console.WriteLine("Version:")
		System.Console.WriteLine(System.Environment.Version)


	LOCAL s := "abcde" AS STRING
	LOCAL c := 'A' AS Char

	s := s:Substring(2,2) + c:ToString() // OK
	s := c:ToString() + c:ToString()       // OK
	s := s:Substring(2,2) + s:ToString() + c:ToString() // OK

	s := s:Substring(2,2) + c:ToString() + s:ToString() // error XS9078: All elements of a string concatenation must be of type 'string'. Element 1 is of type 'char' 

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions