Promotion of sin(x) fails compilation sometimes

I came across a compilation error when using Math + the "only" clause:

use Math; // compilation is successful
// use Math only pi, sin; // compilation fails
const a = 0.0;
const b = 2*pi;
const n = 200;
const dx = (b-a)/n;
const x = [i in 0..n] i*dx;   
const s = sin(x);		 			

When using "Math" alone the program compiles without issues. When using "Math only pi, sin"
the program does not compile, with the following error:

promo.chpl:8: error: unresolved call 'chpl_promo1_sin(x=[domain(1,int(64),one)] real(64), tag=iterKind, followThis=1*range(int(64),both,one))'
promo.chpl:8: note: because no functions named chpl_promo1_sin found in scope

I don't know if this is a compiler bug, or if I am missing something about employing "only" + promotion together.

This was produced in Linux Mint 22.1 running chapel 2.3.0 generated with standard makefile and CHPL_LLVM = system

Hi @nelsonluisdias, this is definitely a compiler bug. Applying any kind of restricted imports interferes with promotion. See Compiler fails to resolve promoted call from another module · Issue #22561 · chapel-lang/chapel · GitHub

-Jade

1 Like

Thanks @jabraham!

1 Like