diff --git a/tests/unit/compiler/test_source_map.py b/tests/unit/compiler/test_source_map.py index d99b546403..abec1a6096 100644 --- a/tests/unit/compiler/test_source_map.py +++ b/tests/unit/compiler/test_source_map.py @@ -97,8 +97,33 @@ def update_foo(): self.foo += 1 """ error_map = compile_code(code, output_formats=["source_map"])["source_map"]["error_map"] - assert "safeadd" in list(error_map.values()) - assert "fallback function" in list(error_map.values()) + assert "safeadd" in error_map.values() + assert "fallback function" in error_map.values() + + +def test_error_map_with_user_error(): + code = """ +@external +def foo(): + raise "some error" + """ + error_map = compile_code(code, output_formats=["source_map"])["source_map"]["error_map"] + assert "user revert with reason" in error_map.values() + + +def test_error_map_not_overriding_errors(): + code = """ +@external +def foo(i: uint256): + raise self.bar(5%i) + +@pure +def bar(i: uint256) -> String[32]: + return "foo foo" + """ + error_map = compile_code(code, output_formats=["source_map"])["source_map"]["error_map"] + assert "user revert with reason" in error_map.values() + assert "safemod" in error_map.values() def test_compress_source_map(): diff --git a/vyper/codegen/ir_node.py b/vyper/codegen/ir_node.py index ff721fafcb..7c089fdb62 100644 --- a/vyper/codegen/ir_node.py +++ b/vyper/codegen/ir_node.py @@ -627,7 +627,7 @@ def from_list( else: return cls( obj[0], - [cls.from_list(o, ast_source=ast_source) for o in obj[1:]], + [cls.from_list(o, ast_source=ast_source, error_msg=error_msg) for o in obj[1:]], typ, location=location, annotation=annotation,