When using a select statement with a negative integer, the program produces an invalid token error. (Invalid token: near '�'). This is a bummer since I wanted to use the select statement to print out debug information for specific codes given by an external C library.
Source Code:
proc main()
{
var errorCode :int = -1;
select errorCode
{
when 0 do writeln("no error");
when −1 do writeln("error present");
when −2 do writeln("error present");
when −3 do writeln("error present");
}
}
// Please provide source code that will reproduce the problem.
// You can insert your code inline if it's not too long.
// Otherwise, you can attach it as a file or provide a URL to it.
// To the extent possible, providing simplified programs demonstrating the
// problem will be appreciated.
// You can also replace this section with "Associated Future Test(s)" below.
`
**Compile command:**
<!-- e.g.chpl foo.chpl-->
chpl main.chpl
**Execution command:**
<!-- e.g../foo -nl 4
If an input file is required, include it as well. -->
./main -nl 1
**Associated Future Test(s):**
<!-- Are there any tests in Chapel's test system that demonstrate this issue?
e.g. [test/path/to/foo.chpl`](
https://github.com/chapel-lang/chapel/blob/master/test/path/to/foo.chpl
) #1234 -->
chpl --version: chpl version 1.20.0$CHPL_HOME/util/printchplenv --anonymize: CHPL_TARGET_PLATFORM: linux64gcc --version or clang --version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0module list:@LeDemz: I think there may be some invisible garbage characters in your source code (?). Specifically, if I cut and paste your code into TIO I see similar failures to what you report: https://tio.run/##S85ILEjN@f@/oCg/WSE3MTNPQ5OrmourLLFIIbWoKL/IOT8lVcEqM69EwVZB19Cai6s4NSc1uQQhCVStAATlGal5CgYKKflAZlFmSWpOnoZSXj5EmZKmNULNo45JhiBlcFVgJQoFRanFqXkl6EqNiFdqjF9pLVft//8A
But if I re-type the code in the lines being reported from scratch, it works as expected: https://tio.run/##jcqxCsJAEIThfp9iSJUUAaOdwconOS4LOTh3j82hheTZz1PBYCNO9cN8fnaJYynJ1OPigrQd3YmuzsBmamedGMcgGSf0w0i0cGSft7Nq1N1mFuwwaU0LmaO0jeibNd24mX54oo95ASTjhSV/w/2/8PAbrrSW8gA
The minus signs for the three negative values in the select statement are unicode minus signs 0xE28892 instead of ascii 0x2D.
Ah, thanks for figuring out what wasn't clear to me, David! This relates somewhat to https://github.com/chapel-lang/chapel/issues/14282 then (the degree to which we could / should permit UTF-8 characters which are arguably similar / equivalents to the ASCII characters we accept today).
Yep! Problem fixed :)
Most helpful comment
Ah, thanks for figuring out what wasn't clear to me, David! This relates somewhat to https://github.com/chapel-lang/chapel/issues/14282 then (the degree to which we could / should permit UTF-8 characters which are arguably similar / equivalents to the ASCII characters we accept today).