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

Report problems with documented functionality
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

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

Post by swagfag » 25 Mar 2021, 03:18

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

User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

Post by kczx3 » 25 Mar 2021, 05:56

Bummer. I quite enjoyed them being assume global

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

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

Post by swagfag » 17 Apr 2021, 21:04

this is fixed in a131

Post Reply

Return to “Bug Reports”