PSyclone
PSyclone copied to clipboard
Literals with precision cannot be used to create a Literal
Passing 1.0_r_def
as name to the Literal constructor aborts (since the string does not match the regular expression).
_real_value = r'^[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?$'
For now I remove _r_def
at the end of a real literal, and _i_def
at the end of an integer literal, but that does not seem to be the best solution.
Note that the above solution is wrong and an obvious bad work around, since different precisions could be used, which will still cause an exception. Plus the existing code in #1883, scalar() hard-codes the precision to be i_def
or r_def
, so care must be taken if there is a precision specified, to declare the literals appropriately.
The locations mentioned in #1920 are also useful here - at this stage the tree is still intact and has precision split into a separate element, which is only then combined back into a single string.
Unless I'm missing something, the precision should become part of the datatype
that is provided to the Literal
constructor?
Can this be closed now? Ultimately, we will use PSyIR for the Algorithm layer which will then remove this problem altogether as the kernel argument list will all be in PSyIR.
OK, I've followed the suggested way of using psyir_from_expression
, and this avoids the problem, so I'm ok with closing this.