Skip to content

Ward gets confused by multiple statements on a single line #11

Description

@fingolfin

In the process of aligning the codebases in master and hpcgap-default, I made commit f862255ff449fcb85228cebc1862d6cd7680eb32 which basically only changes whitespace, yet causes HPC-GAP to segfault.

Eventually, I discovered this was due to the changes in oper.c, which confused ward. Consider this diff:

@@ -1751,8 +1752,7 @@ Obj DoOperation1Args (
     Obj                 prec;

     /* get the types of the arguments                                      */
-    type1 = TYPE_OBJ_FEO( arg1 );
-    id1 = ID_TYPE( type1 );
+    type1 = TYPE_OBJ_FEO( arg1 );  id1 = ID_TYPE( type1 );

     /* try to find an applicable method in the cache                       */
     cache = 1+ADDR_OBJ( CacheOper( oper, 1 ) );

The old code (on two lines) causes ward to output this:

    type1 = TYPE_OBJ_FEO( arg1 );
    ReadGuard(type1);
    id1 = ID_TYPE( type1 );

The new code (on one line) causes ward to output this:

    ReadGuard(type1),
    type1 = TYPE_OBJ_FEO( arg1 );  id1 = ID_TYPE( type1 );

While I can of course just revert that commit, I think this is a rather sever issue, as new code is likely to run into this issue again. Plus, I really prefer in this particular case to have the two statements on one line (I usually never, but this is one of the few cases where I think "breaking the rules" is justified).

Ideally, this should just be handled right, possibly by ward inserting a newline after the first semicolon; if that is infeasible, perhaps at least an error can be triggered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions