File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -339,6 +339,18 @@ fn use_type_from_type_field() {
339339 assert_eq ! ( actual, Test :: B ( "abc" . to_string( ) ) ) ;
340340}
341341
342+ #[ test]
343+ fn use_rust_created_tuple_as_polymorphic ( ) {
344+ let _ = :: env_logger:: try_init ( ) ;
345+ let test = r"\x -> x._0" ;
346+ let mut vm = make_vm ( ) ;
347+ load_script ( & mut vm, "test" , test) . unwrap_or_else ( |err| panic ! ( "{}" , err) ) ;
348+
349+ let mut f: FunctionRef < fn ( ( i32 , String ) ) -> VmInt > = vm. get_global ( "test" ) . unwrap ( ) ;
350+ let result = f. call ( ( 1 , "" . to_string ( ) ) ) . unwrap ( ) ;
351+ assert_eq ! ( result, 1 ) ;
352+ }
353+
342354#[ test]
343355fn use_rust_created_record_as_polymorphic ( ) {
344356 let _ = :: env_logger:: try_init ( ) ;
Original file line number Diff line number Diff line change @@ -1687,7 +1687,13 @@ macro_rules! define_tuple {
16871687 $id. push( context) ?;
16881688 ) +
16891689 let len = count!( $( $id) ,+) ;
1690- context. context( ) . push_new_data( 0 , len) ?;
1690+ let thread = context. thread( ) ;
1691+ #[ allow( unused_assignments) ]
1692+ let field_names = {
1693+ let mut i = 0 ;
1694+ [ $( thread. global_env( ) . intern( & format!( "_{}" , { let _ = $id; let x = i; i += 1 ; x } ) ) ?) ,* ]
1695+ } ;
1696+ context. context( ) . push_new_record( len, & field_names) ?;
16911697 Ok ( ( ) )
16921698 }
16931699 }
You can’t perform that action at this time.
0 commit comments