Illegal Default Parameters
Closed this issue · 3 comments
In AutoHotkey v1 parameters can be defined using either =
or :=
assignment operators for default values.
In AutoHotkey v2 parameters must use :=
for default assignments.
In this "translator" the style is not translated correctly as it allows either of v1's operators to be used.
I'm happy to see this got a first issue, ty
input
foo(a=str) {
}
everythingV1
[
{type:'function DEFINITION name', text:'foo', i1:0, c1:0, c2:3},
{type:'( function DEFINITION', text:'(', i1:0, c1:3},
{type:'start unit'},
{type:'Param', text:'a', i1:0, c1:4, c2:5},
{type:'end unit'},
{type:'1operator', text:'=', i1:0, c1:5},
{type:'start unit'},
{type:'idkVariable', text:'str', i1:0, c1:6, c2:9},
{type:'end unit'},
{type:') function DEFINITION', text:')', i1:0, c1:9},
{type:'emptyLines', text:' ', i1:0, c1:10, i2:0, c2:11},
{type:'{ function DEFINITION', text:'{', i1:0, c1:11},
{type:'newLine startOfLineLoop', text:'
', i1:0, c1:12},
{type:'} unknown', text:'}', i1:1, c1:0},
]
so if I have type:'1operator', text:'='
after type:'Param'
I should transform it into type:'2operator', text:':='
but type:'idkVariable', text:'str'
shouldn't be idkVariable, it should be v1Str
wait, no
thankfully foo(a=str) {
is illegal, foo(a="str") {
is legal
so that's easy
test it, and you, close it if it's fixed
so in the PARSER, not the CONVERTER, I made it so that in a function definition, if I have type:'1operator', text:'='
after type:'Param'
, I would change its type to = v1Assignment
, try it now and you will see that it is indeed type:'= v1Assignment', text:'='
this took 2 seconds to fix :
I wanted to finish converting RunCMD() first, to not mess up my commit history, or undo what I was doing
if I stashed my work and fixed this first, I would probably get a merge conflict when I apply the stash, oof
this is inflexible and I have to keep in mind everything I want to do next