Skip to content

main function definition not on its own line is not detected #624

Open
@MonliH

Description

@MonliH

After entering the following code:

use std; fn main(){ println!("Hello, world!"); }

and clicking the "Build" button, I get the following message:

No main function was detected, so your code was compiled
but not run. If you’d like to execute your code, please
add a main function.

No code in the main function is run.



After a bit more testing, I've found that if the main function's signature is not on its own line, the playground fails to detect the function:

// Also doesn't detect main
const foo: i32 = 10; fn main(){}

// Also doesn't detect main
use std; fn main(){
}

// Does detect main
use std;
fn main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething new the playground could dohelp wantedNot immediately going to be prioritized — ask for mentoring instructions!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions