NotImplementedError: Cannot take length of non-vector expression

Hi, I am trying to follow Dokken’s tutorial on the Navier-Stokes equations for the Poiseuille flow in a pipe, but when I reach the variational formulation ot the second step, the code throws the excepcion:

NotImplementedError: Cannot take length of non-vector expression.

Here is a MWE of the code.

from mpi4py import MPI

from dolfinx.fem import FunctionSpace, form
from dolfinx.mesh import create_unit_square
from ufl import (FiniteElement, TestFunction, TrialFunction,
                 VectorElement, dot, dx, nabla_grad, grad)

mesh = create_unit_square(MPI.COMM_WORLD, 10, 10)

v_cg2 = VectorElement("CG", mesh.ufl_cell(), 2)
s_cg1 = FiniteElement("CG", mesh.ufl_cell(), 1)
V, Q = FunctionSpace(mesh, v_cg2), FunctionSpace(mesh, s_cg1)

u = TrialFunction(V)
v = TestFunction(V)
p = TrialFunction(Q)
q = TrialFunction(Q)


# Define variational problem for step 2
a2 = form(dot(grad(p), grad(q))*dx)  # this is the line that gives the error

I also tried to substitute the line mentioned above with:

a2 = form(dot(grad(p), grad(q))*dx)

(which btw is how it is written in the tutorial), but it throws the same error.

Any guidance or ideas on how to solve this would be appreciated. Thank you.

p and q should not both be TrialFunctions