Unable to use ooc-style argument of main in match #866

Closed
zhaihj opened this Issue Feb 24, 2015 · 1 comment

Projects

None yet

2 participants

@zhaihj
Contributor
zhaihj commented Feb 24, 2015
main: func(args: ArrayList<String>){
    match(args size){
        case 1 => "%s" printfln(args[0])
        case => 
    }
}

generates :

rock/test.ooc:5:33 error Undefined symbol 'args'
        case 1 => "%s" printfln(args[0])
                                ~~~~    

[FAIL]

because we replaced args with __%module%__main

A simple and dirty hack can be as follows:

vdfe1 := VariableDecl new(null, arg getName(), VariableAccess new(vdfe, token), token)
body add(0, vdfe1)

for main: func(args: ArrayList<String>), this finally generates:

__%module%__args := strArrayListFromCString(argc, argv)
arg := __%module%__args
@zhaihj zhaihj changed the title from match do not works well with arguments of main to match does not work well with arguments of main Feb 24, 2015
@zhaihj zhaihj changed the title from match does not work well with arguments of main to Unable to use ooc-style argument of main in match Feb 24, 2015
@fasterthanlime
Collaborator

I wonder why we're mangling the argument's name in the first place..

@fasterthanlime fasterthanlime modified the milestone: 0.9.10 Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment