dace icon indicating copy to clipboard operation
dace copied to clipboard

String literal evaluated as variable in callback parameters

Open FlorianDeconinck opened this issue 3 years ago • 0 comments

When passing a string literal in a callback argument which value is the exact name of another variable, it gets swapped with the variable __repr__ instead of being treated as a string literal.

Code:

import dace
import numpy as np

def force_callback(fn):
    return fn

@force_callback
def a_callback(an_arr: np.ndarray, a_name: str):
    print(
        a_name
    )  # < This should print "an_arr" but will print the __repr__ of an_arr instead

@dace.program
def the_program(an_arr):
    an_arr[:] = 4
    a_callback(an_arr, "an_arr") # < any other string literal works fine

an_arr = np.ones((10))
the_program(an_arr)

Expecting: an_arr to be printed, but getting [4. 4. 4. 4. 4. 4. 4. 4. 4. 4.]

FlorianDeconinck avatar Jul 28 '22 15:07 FlorianDeconinck