Skip to content

Commit

Permalink
Disable inlined defaults when inlining the function body.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Sep 24, 2024
1 parent 97908c6 commit 3e5230d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 8 additions & 4 deletions edb/edgeql/compiler/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,9 @@ def compile_FunctionCall(
# TODO: Global parameters still use the implicit globals parameter.
# They should be directly substituted in whenever possible.

inline_args: dict[int | str, irast.CallArg | irast.Set] = {}
inline_args: dict[str, irast.CallArg | irast.Set] = {}

# Collect non-default call args to inline
for param_shortname, arg_key in param_name_to_arg_key.items():
if (
isinstance(arg_key, int)
Expand All @@ -388,6 +389,9 @@ def compile_FunctionCall(
continue

arg = final_args[arg_key]
if arg.is_default:
continue

inline_args[param_shortname] = arg

# Package variadic arguments into an array
Expand Down Expand Up @@ -416,7 +420,7 @@ def compile_FunctionCall(
for param in matched_func_params.objects(env.schema):
param_shortname = param.get_parameter_name(env.schema)

if param_shortname in param_name_to_arg_key:
if param_shortname in inline_args:
continue

else:
Expand Down Expand Up @@ -462,7 +466,6 @@ def compile_FunctionCall(
arg.expr,
optional=(
arg.param_typemod == ft.TypeModifier.OptionalType
or arg.is_default
),
ctx=ctx,
)
Expand All @@ -474,10 +477,11 @@ def compile_FunctionCall(
class ArgumentInliner(ast.NodeTransformer):

mapped_args: dict[irast.PathId, irast.PathId]
inlined_arg_keys: list[int | str]

def __init__(
self,
inline_args: dict[int | str, irast.CallArg | irast.Set],
inline_args: dict[str, irast.CallArg | irast.Set],
ctx: context.ContextLevel,
) -> None:
super().__init__()
Expand Down
5 changes: 4 additions & 1 deletion edb/edgeql/compiler/polyres.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ def _get_cast_distance(
variadic_arg_id: Optional[int] = None
variadic_arg_count: Optional[int] = None
no_args_call = not args and not kwargs
has_inlined_defaults = func.has_inlined_defaults(schema)
has_inlined_defaults = (
func.has_inlined_defaults(schema)
and not func.get_is_inlined(schema)
)

func_params = func.get_params(schema)

Expand Down
5 changes: 4 additions & 1 deletion edb/schema/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,10 @@ def get_compiler_options(
inlining_context: Optional[qlcontext.ContextLevel] = None,
) -> qlcompiler.CompilerOptions:

has_inlined_defaults = bool(params.find_named_only(schema))
has_inlined_defaults = (
bool(params.find_named_only(schema))
and inlining_context is None
)

param_anchors = get_params_symtable(
params,
Expand Down

0 comments on commit 3e5230d

Please sign in to comment.