# Buggy code
def ann_assign(self):
    self.context.set_in_assignment(True)
    typ = parse_type(
        self.stmt.annotation, location="memory", custom_units=self.context.custom_units
    )
    if (
        isinstance(self.stmt.target, ast.Attribute)
        and self.stmt.target.value.id == "self"
    ):
        raise TypeMismatchException("May not redefine storage variables.", self.stmt)
    varname = self.stmt.target.id
    pos = self.context.new_variable(varname, typ)
    o = LLLnode.from_list("pass", typ=None, pos=pos)
    if self.stmt.value is not None:
        sub = Expr(self.stmt.value, self.context).lll_node
        self._check_valid_assign(sub)
        self._check_same_variable_assign(sub)
        variable_loc = LLLnode.from_list(
            pos, typ=typ, location="memory", pos=getpos(self.stmt)
        )
        o = make_setter(variable_loc, sub, "memory", pos=getpos(self.stmt))
    self.context.set_in_assignment(False)
    return o


# Traceback (AttributeError)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51879)
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 717, in __init__
self.handle()
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 426, in handle
self.handle_one_request()
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 414, in handle_one_request
method()
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/EGG-INFO/scripts/vyper-serve", line 66, in do_POST
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/EGG-INFO/scripts/vyper-serve", line 89, in _compile
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/compiler.py", line 44, in mk_full_signature
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/compiler.py", line 27, in gas_estimate
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 794, in parse_to_lll
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 224, in parse_tree_to_lll
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 172, in parse_other_functions
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 530, in parse_func
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 530, in <listcomp>
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 547, in parse_body
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/parser.py", line 601, in parse_stmt
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/stmt.py", line 76, in __init__
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/stmt.py", line 150, in ann_assign
File "/Users/ryuya.nakamura/work/vyper/venv/lib/python3.7/site-packages/vyper-0.1.0b4-py3.7.egg/vyper/parser/stmt.py", line 105, in _check_valid_assign
AttributeError: 'ByteArrayType' object has no attribute 'typ'
----------------------------------------

# Fixed code
def ann_assign(self):
    self.context.set_in_assignment(True)
    typ = parse_type(
        self.stmt.annotation, location="memory", custom_units=self.context.custom_units
    )
    if (
        isinstance(self.stmt.target, ast.Attribute)
        and self.stmt.target.value.id == "self"
    ):
        raise TypeMismatchException("May not redefine storage variables.", self.stmt)
    varname = self.stmt.target.id
    pos = self.context.new_variable(varname, typ)
    o = LLLnode.from_list("pass", typ=None, pos=pos)
    if self.stmt.value is not None:
        sub = Expr(self.stmt.value, self.context).lll_node
        # If bytes[32] to bytes32 assignment rewrite sub as bytes32.
        if (
            isinstance(sub.typ, ByteArrayType)
            and sub.typ.maxlen == 32
            and isinstance(typ, BaseType)
            and typ.typ == "bytes32"
        ):
            bytez, bytez_length = string_to_bytes(self.stmt.value.s)
            sub = LLLnode(
                bytes_to_int(bytez), typ=BaseType("bytes32"), pos=getpos(self.stmt)
            )
        self._check_valid_assign(sub)
        self._check_same_variable_assign(sub)
        variable_loc = LLLnode.from_list(
            pos, typ=typ, location="memory", pos=getpos(self.stmt)
        )
        o = make_setter(variable_loc, sub, "memory", pos=getpos(self.stmt))
    self.context.set_in_assignment(False)
    return o