Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

@zhaihj
Copy link
Contributor

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 match do not works well with arguments of main match does not work well with arguments of main Feb 24, 2015

@zhaihj zhaihj changed the title match does not work well with arguments of main Unable to use ooc-style argument of main in match Feb 24, 2015

@fasterthanlime

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.