Fix enums defined in submodules

This commit is contained in:
Alex Crichton 2018-05-02 10:16:40 -07:00
parent 6c28e5f273
commit 4304a262c6
2 changed files with 12 additions and 6 deletions

View File

@ -763,7 +763,7 @@ impl ToTokens for ast::Enum {
_extra: &mut ::wasm_bindgen::convert::Stack, _extra: &mut ::wasm_bindgen::convert::Stack,
) -> Self { ) -> Self {
#(#cast_clauses else)* { #(#cast_clauses else)* {
wasm_bindgen::throw("invalid enum value passed") ::wasm_bindgen::throw("invalid enum value passed")
} }
} }
} }

View File

@ -52,12 +52,18 @@ fn c_style_enum_with_custom_values() {
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
pub mod inner {
use wasm_bindgen::prelude::*;
#[wasm_bindgen] #[wasm_bindgen]
pub enum Color { pub enum Color {
Green = 21, Green = 21,
Yellow = 34, Yellow = 34,
Red, Red,
} }
}
use inner::Color;
#[wasm_bindgen] #[wasm_bindgen]
pub fn cycle(color: Color) -> Color { pub fn cycle(color: Color) -> Color {