Skip to content

Cannot import and export function of the same name #1496

Closed
@alexcrichton

Description

@alexcrichton

Currently this generates invalid JS:

#[wasm_bindgen(module = "foo")]   
extern "C" {                      
    #[wasm_bindgen(js_name = foo)]
    pub fn bar(a: u32);           
}                                 
                                  
#[wasm_bindgen]                   
pub fn foo() {                    
    bar(3);                       
}                                 

as it looks like:

import { foo } from 'foo';                        
import * as wasm from './add_bg';                 
                                                  
export function __wbg_foo_562f86fd7faf408e(arg0) {
    foo(arg0 >>> 0);                              
}                                                 
/**                                               
* @returns {void}                                 
*/                                                
export function foo() {                           
    return wasm.foo();                            
}                                                 

but that imports the name foo and also exports it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions