Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix source code annotation for sqrt #2691

Merged
merged 6 commits into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vyper/builtin_functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@
from vyper.codegen.stmt import parse_body


def _strip_source_pos(ir_node):
ir_node.source_pos = None
for x in ir_node.args:
_strip_source_pos(x)


def generate_inline_function(code, variables, memory_allocator):
ast_code = parse_to_ast(code)
new_context = Context(
vars_=variables, global_ctx=GlobalContext(), memory_allocator=memory_allocator
)
generated_ir = parse_body(ast_code.body, new_context)
# strip source position info from the generated_ir since
# it doesn't make any sense (e.g. the line numbers will start from 0
# instead of where we are in the code)
# NOTE if we ever use this for inlining user-code, it would make
# sense to fix the offsets of the source positions in the generated
# code instead of stripping them.
_strip_source_pos(generated_ir)
return new_context, generated_ir