chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 420 forks source link

[Bug]: writeRange #25940

Closed tkphd closed 1 month ago

tkphd commented 1 month ago

Summary of Problem

Description:

I would like to use writeRange to print the values in a range. With Chapel 2.1.0, the primer code ranges.chpl fails to compile.

Steps to Reproduce

Source Code:

const r = 1..10;
writeRange(r);

Compile command:

$ chpl ranges.chpl -o rangetest.o
ranges.chpl:2: error: unresolved call 'writeRange(range(int(64),both,one))'
ranges.chpl:2: note: because no functions named writeRange found in scope

Configuration Information

jabraham17 commented 1 month ago

Hi @tkphd, ranges.chpl compiles for me fine with Chapel 2.1.

Just to make sure I understand, are you literally compiling this source file, or trying to use writeRange(r); in your own source file? I think its the latter, in which case that is expected. writeRange is a helper function defined inside of the source file for that primer, not a standard library function. If you want to make use of that function, you will need to copy it to your application.

If you are just trying to print out the range, you can use Chapel's normal writeln function

tkphd commented 1 month ago

ah-HA!! Coming from C & Python, I expected function declarations at the top, and missed this one. Thanks!