Add check for Array type in doc.canonicalize to avoid segfaulting when called with wrong type.