Page 1 of 1

[a129] fat-arrow shorthand functions are still assume-global

Posted: 25 Mar 2021, 03:18
by swagfag
this is from https://www.autohotkey.com/boards/viewtopic.php?p=387381#p387381 lest it gets buried
one change in a128(https://www.autohotkey.com/boards/viewtopic.php?f=37&t=2120&start=80#p385995) was:
Fat arrow functions in global scope are no longer assume-global. Due to the new rules, they can read global variables and create local variables, but not assign global variables.

Code: Select all

#Requires AutoHotkey v2.0-a129-78d2aa15

v := 1

f() => v := 8 ; assigns 8 to GLOBAL variable v when called. this is unexpected

; f := () => v := 8 ; assigns 8 to LOCAL variable v when called. this is expected

; f() {
; 	v := 8 ; assigns 8 to LOCAL variable v when called. this is expected
; }

MsgBox v ; 1
f()
MsgBox v ; 8, this is unexpected

Re: [a129] fat-arrow shorthand functions are still assume-global

Posted: 25 Mar 2021, 05:56
by kczx3
Bummer. I quite enjoyed them being assume global

Re: [a129] fat-arrow shorthand functions are still assume-global  Topic is solved

Posted: 17 Apr 2021, 21:04
by swagfag
this is fixed in a131