Closed Banaanae closed 1 week ago
~~Turns out putting in brackets works Submitting fix now~~ Not perfect fix :/ ill see if theres alternatives
The problem with this is v1 returns first statement while v2 returns last
Return (a := 1, b := a + 1)
; ^ ^
; v1 v2
We could either copy first statement to the back
Return (a := 1, b := a + 1, a := 1) ; Or even just 'a'
; For example
Return SomeFuncValue(), ErrorLevel := 0
; ->
Return (V1toV2_Temp := SomeFuncValue(), ErrorLevel := 0, V1toV2_Temp)
Or give warning
Return (a := 1, b := a + 1) ; V1toV2: Now returns last statement instead of first
I came across this in my attempt to convert VisualDiff to ah2, before giving up, and added this to ConvertFuncs.ahk ...
if InStr(Line, 'return')
{
checkReturnParams(&Line)
}
checkReturnParams(&Line)
{
cc := po := pc := ip := 0
cpa := []
for i, char in StrSplit(Line) {
if char = ','
cc++, cpa.Push(i)
else if char = '('
po := i
else if char = ')'
pc := i
}
for _, index in cpa {
if po && pc && (index > po && index < pc)
ip++
}
if ip != cc {
Line := RegExReplace(Line, 'i)^(\s*return\s*)(.*)', '$1($2)')
Line .= ' `; V1toV2: Multiple params enclosed in parantheses'
}
}
¯\(ツ)/¯
V1:
V2 (Converted):
V2 (Expected):
Return now only accepts 1 param
Expected needs more work, because above logic does not work with below