External Issue: write and writeln does not support type argument

16917, “rchinmay”, “write and writeln does not support type argument”, “2021-01-08T09:43:45Z”

Summary of Problem

In chapel 1.23.0, write() and writeln() does not support type arguments. I don’t know if there is any reason for that. But, in python3 print(type(a)) is valid. In the code given below, if the commented lines were uncommented, then it produces a compilation error when both the arguments are equal. In my opinion, it should have printed <int> while printing the type value.

Steps to Reproduce

Source Code:

proc getType(a:?ta, b:?tb){
  if(ta==tb){
    //write(a, " and ", b, " are of type ", ta);
    //writeln(ta);
  }
  else{
    writeln(a," and ", b, " are of different types");
  }
}

getType(1,1);
type t=int;
//writeln(t);

Compile command:
chpl Chapel_Program.chpl --print-all-candidates
Error shown if the two arguments are of same type:

Chapel_Program.chpl:3: error: unresolved call 'write(int(64), " and ", int(64), " are of type ", type int(64))'
$CHPL_HOME/modules/internal/ChapelIO.chpl:836: note: this candidate did not match: write(const args ...?n)
Chapel_Program.chpl:3: note: because type call actual argument #5
$CHPL_HOME/modules/internal/ChapelIO.chpl:836: note: is passed to non-type formal 'const _e4_args'
$CHPL_HOME/modules/internal/Atomics.chpl:237: note: candidates are: AtomicBool.write(value: bool, param order: memoryOrder = memoryOrder.seqCst)
$CHPL_HOME/modules/internal/Atomics.chpl:422: note:                 AtomicT.write(value: T, param order: memoryOrder = memoryOrder.seqCst)
$CHPL_HOME/modules/internal/NetworkAtomics.chpl:62: note:                 RAtomicBool.write(value: bool, param order: memoryOrder = memoryOrder.seqCst)
$CHPL_HOME/modules/internal/NetworkAtomics.chpl:169: note:                 RAtomicT.write(value: T, param order: memoryOrder = memoryOrder.seqCst)
  Chapel_Program.chpl:11: called as getType(a: int(64), b: int(64))
note: generic instantiations are underlined in the above callstack

Execution command:
./Chapel_Program
If the arguments are not equal, then it runs correctly (as expected).

Configuration Information

  • Output of chpl --version:
chpl version 1.23.0
Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none *
CHPL_TASKS: fifo *
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: cstdlib *
CHPL_ATOMICS: cstdlib
CHPL_GMP: none *
CHPL_HWLOC: none
CHPL_REGEXP: none *
CHPL_LLVM: none *
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks,
R.Chinmay