-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
Problem Statement
There is a problem (bug?) in PQ around re-using function argument names on local variables (immutable though they are) within the function. This is not a problem if you invoke directly, but if you are invoking as a parameter in a host function, the above error is thrown. The problem occurs in...
Value.ToTextType.ToTextValue.TypeToText
Resolution
All of these have an optional argument signifying recursive types and the same name is recycled in the function body. Simply change the name of the local variable and all is OK.
e.g. in Value.TypeToText change Recurs to _Recurs
let
Source = (Value as any, optional Recurs as logical) as text =>
let
Recurs = if (Recurs<>null) then Recurs else false,
Type.ToText = #"Load"("Type.ToText"),
Type = Value.Type(Value),
ToText = if Value.Is(Value, type type) and Recurs then
"type " & Type.ToText(Value, Recurs)
else
Type.ToText(Type, Recurs),
Return = ToText
in Return
in
Source
To
(Value as any, optional Recurs as logical) as text =>
let
_Recurs = if (Recurs<>null) then Recurs else false,
Type.ToText = Load("Type.ToText"),
Type = Value.Type(Value),
ToText = if Value.Is(Value, type type) and _Recurs then
"type " & Type.ToText(Value, _Recurs)
else
Type.ToText(Type, _Recurs),
Return = ToText
in Return
Took me a while to figure this out but, much shorter than writing it myself: thanks for the share!
I won't be using the dynamic loading, but it's the closest I've seen to a build tool in PQ.
Metadata
Metadata
Assignees
Labels
No labels