@@ -987,7 +987,7 @@ fn property_separator(i: &mut TokenSlice) -> ModalResult<()> {
987
987
// Normally you need a comma.
988
988
comma_sep,
989
989
// But, if the object is ending, no need for a comma.
990
- peek ( preceded ( opt ( whitespace) , close_brace) ) . void ( ) ,
990
+ peek ( preceded ( ( opt ( non_code_node ) , opt ( whitespace) ) , close_brace) ) . void ( ) ,
991
991
) )
992
992
. parse_next ( i)
993
993
}
@@ -1017,7 +1017,7 @@ pub(crate) fn object(i: &mut TokenSlice) -> ModalResult<Node<ObjectExpression>>
1017
1017
let properties: Vec < _ > = repeat (
1018
1018
0 ..,
1019
1019
alt ( (
1020
- terminated ( non_code_node. map ( NonCodeOr :: NonCode ) , whitespace) ,
1020
+ terminated ( non_code_node. map ( NonCodeOr :: NonCode ) , opt ( whitespace) ) ,
1021
1021
terminated (
1022
1022
alt ( ( object_property, object_property_same_key_and_val) ) ,
1023
1023
property_separator,
@@ -4861,6 +4861,26 @@ export fn cos(num: number(rad)): number(_) {}"#;
4861
4861
let _arr = array_elem_by_elem ( & mut tokens. as_slice ( ) ) . unwrap ( ) ;
4862
4862
}
4863
4863
4864
+ #[ test]
4865
+ fn object_no_trailing_comma_with_comment ( ) {
4866
+ let program = r#"{
4867
+ x=1, // one
4868
+ y=2, // two
4869
+ z=3 // three
4870
+ }"# ;
4871
+ let module_id = ModuleId :: default ( ) ;
4872
+ let tokens = crate :: parsing:: token:: lex ( program, module_id) . unwrap ( ) ;
4873
+ let _arr = object ( & mut tokens. as_slice ( ) ) . unwrap ( ) ;
4874
+ }
4875
+
4876
+ #[ test]
4877
+ fn object_block_comment_no_whitespace ( ) {
4878
+ let program = r#"{x=1/* comment*/}"# ;
4879
+ let module_id = ModuleId :: default ( ) ;
4880
+ let tokens = crate :: parsing:: token:: lex ( program, module_id) . unwrap ( ) ;
4881
+ let _arr = object ( & mut tokens. as_slice ( ) ) . unwrap ( ) ;
4882
+ }
4883
+
4864
4884
#[ test]
4865
4885
fn basic_if_else ( ) {
4866
4886
let some_program_string = "if true {
0 commit comments