I'm experiencing a strange phenomenon. Here's a (quite artificial) test case:

The following definition work just fine:

    f[x___Real]:={x}
    g[a_,f[n_Integer]]:={a,n}
    SetAttributes[f,Flat]

    f[a,f[b,c]]
    (*
     --> f[a,b,c]
    *)

    g[f[1.0],3]
    (*
     --> g[{1.},3]
    *)

As do the following (in a fresh kernel):

    f[x___Real]:={x}
    SetAttributes[f,Flat]
    g[a_,f[n_Integer]]:={a,n}

    f[a,f[b,c]]
    (*
     --> f[a,b,c]
    *)
    
    g[f[1.0],3]
    (*
     --> g[{1.},3]
    *)

However, the following (evaluated in a fresh kernel again) hangs on the definition of `g`:

    SetAttributes[f,Flat]
    f[x___Real]:={x}
    g[a_,f[n_Integer]]:={a,n}

Now I don't see any reason why the definition of `g` should depend on whether I've first defined `f` or first set the `Flat` attribute on it. Can anyone explain the mystery?

PS: If anyone can think of a better title, feel free to change it accordingly.