Skip to content

Commit

Permalink
Merge #646
Browse files Browse the repository at this point in the history
646: Fix Type::variant call for VmType derive r=Marwes a=Laegluin

Fixes `Type::variant` still being referred to as `Type::variants` in the `VmType` derive, which is currently broken for enums because of it.

Co-authored-by: Robin Mirow <robinmirow@live.com>
  • Loading branch information
bors[bot] and Laegluin committed Oct 17, 2018
2 parents 360f578 + 48e1e11 commit 6c79166
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion codegen/src/vm_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn gen_impl(container: &Container, ident: Ident, generics: Generics, data: &Data
}}
});
quote!{
_gluon_base::types::Type::variants(
_gluon_base::types::Type::variant(
vec![#(#variants),*]
)
}
Expand Down
18 changes: 18 additions & 0 deletions codegen/tests/derive_vm_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ fn struct_() {
);
}

#[derive(VmType)]
#[allow(unused)]
enum Enum {
One,
Two(u32),
Three { id: String },
}

#[test]
fn enum_() {
let vm = new_vm();

assert_eq!(
Enum::make_type(&vm).to_string(),
"| One\n| Two Int\n| Three String"
);
}

#[derive(VmType)]
#[allow(unused)]
struct Newtype(Struct);
Expand Down

0 comments on commit 6c79166

Please sign in to comment.