Chapel: invalid token when using select statement with negative integer values

Created on 24 Apr 2020  Â·  4Comments  Â·  Source: chapel-lang/chapel

Summary of Problem

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.

Steps to Reproduce

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 -->

Configuration Information

  • Output of chpl --version: chpl version 1.20.0
  • Output of $CHPL_HOME/util/printchplenv --anonymize: CHPL_TARGET_PLATFORM: linux64
    CHPL_TARGET_COMPILER: gnu
    CHPL_TARGET_ARCH: x86_64
    CHPL_TARGET_CPU: native *
    CHPL_LOCALE_MODEL: flat
    CHPL_COMM: gasnet *
    CHPL_COMM_SUBSTRATE: smp *
    CHPL_GASNET_SEGMENT: fast *
    CHPL_TASKS: qthreads
    CHPL_LAUNCHER: smp *
    CHPL_TIMERS: generic
    CHPL_UNWIND: none
    CHPL_MEM: jemalloc
    CHPL_ATOMICS: cstdlib
    CHPL_NETWORK_ATOMICS: none
    CHPL_GMP: gmp
    CHPL_HWLOC: hwloc
    CHPL_REGEXP: re2
    CHPL_LLVM: llvm *
    CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
  • (For Cray systems only) Output of module list:

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).

All 4 comments

@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 :)

Was this page helpful?
0 / 5 - 0 ratings