Repository: vyperlang/vyper

Issue:
AttributeError: 'str' object has no attribute 'compare_type'
### Version Information

* vyper Version (output of `vyper --version`): 0.3.3
* OS: macOS
* Python Version (output of `python --version`): 2.7.16

### What's your issue about?
```
vyper-0.3.3 error: AttributeError: 'str' object has no attribute 'compare_type'
[14131] Failed to execute script 'vyper_compile' due to unhandled exception!
```
```
event E:
    _: DynArray[DynArray[uint256, 5], 5]

@external
def createEvent(x: uint256):
    arr: DynArray[DynArray[uint256, 5], 5] = [[], []]
    arr[0] = [0, 0]
    arr[1] = [0, 0]
    arr[0][0] = x
    arr[0][1] = x + 1
    arr[1][0] = x + 2
    arr[1][1] = x + 3
    log E(arr)
    
```



Discussion:
note to self: revisit after refactoring type system
minimal repro
```
@external
def createEvent(x: uint256):
    arr: DynArray[DynArray[uint256, 5], 5] = [[], []]
```

Resolving patch:
diff --git a/vyper/semantics/validation/utils.py b/vyper/semantics/validation/utils.py
--- a/vyper/semantics/validation/utils.py
+++ b/vyper/semantics/validation/utils.py
@@ -236,16 +236,15 @@ def types_from_Constant(self, node):
         raise InvalidLiteral(f"Could not determine type for literal value '{node.value}'", node)
 
     def types_from_List(self, node):
-        # literal array
 
-        if not node.elements:
+        # literal array
+        if _is_empty_list(node):
             # empty list literal `[]`
             # subtype can be anything
             types_list = types.get_types()
             # 1 is minimum possible length for dynarray, assignable to anything
-            ret = [DynamicArrayDefinition(t, 1) for t in types_list]
+            ret = [DynamicArrayDefinition(v, 1) for v in types_list.values()]
             return ret
-
         types_list = get_common_types(*node.elements)
 
         if len(types_list) > 0:
@@ -254,7 +253,6 @@ def types_from_List(self, node):
             ret.extend([ArrayDefinition(t, count) for t in types_list])
             ret.extend([DynamicArrayDefinition(t, count) for t in types_list])
             return ret
-
         raise InvalidLiteral("Array contains multiple, incompatible types", node)
 
     def types_from_Name(self, node):
@@ -295,6 +293,18 @@ def types_from_UnaryOp(self, node):
         return _validate_op(node, types_list, "validate_numeric_op")
 
 
+def _is_empty_list(node):
+    # Checks if a node is a `List` node with an empty list for `elements`,
+    # including any nested `List` nodes. ex. `[]` or `[[]]` will return True,
+    # [1] will return False.
+    if not isinstance(node, vy_ast.List):
+        return False
+
+    if not node.elements:
+        return True
+    return all(_is_empty_list(t) for t in node.elements)
+
+
 def _is_type_in_list(obj, types_list):
     # check if a type object is in a list of types
     return any(i.compare_type(obj) for i in types_list)


Test patch:
diff --git a/tests/parser/types/test_dynamic_array.py b/tests/parser/types/test_dynamic_array.py
--- a/tests/parser/types/test_dynamic_array.py
+++ b/tests/parser/types/test_dynamic_array.py
@@ -1648,6 +1648,24 @@ def __init__():
             assert c.my_list(i, j) == t
 
 
+@pytest.mark.parametrize(
+    "typ,val",
+    [
+        ("DynArray[DynArray[uint256, 5], 5]", [[], []]),
+        ("DynArray[DynArray[DynArray[uint256, 5], 5], 5]", [[[], []], []]),
+    ],
+)
+def test_empty_nested_dynarray(get_contract, typ, val):
+    code = f"""
+@external
+def foo() -> {typ}:
+    a: {typ} = {val}
+    return a
+    """
+    c = get_contract(code)
+    assert c.foo() == val
+
+
 # TODO test negative public(DynArray) cases?
 
 # CMC 2022-08-04 these are blocked due to typechecker bug; leaving as