diff --git a/edb/edgeql/compiler/casts.py b/edb/edgeql/compiler/casts.py index 70ce470cecd..d60474363e7 100644 --- a/edb/edgeql/compiler/casts.py +++ b/edb/edgeql/compiler/casts.py @@ -74,7 +74,7 @@ def compile_cast( ) -> irast.Set: if new_stype.is_polymorphic(ctx.env.schema) and span is not None: - # If we have no srcctx we don't know whether this is a direct cast + # If we have no span we don't know whether this is a direct cast # or some implicit cast being processed. raise errors.QueryError( f'cannot cast into generic type ' @@ -154,11 +154,11 @@ def compile_cast( ) ): return _cast_array_literal( - ir_set, orig_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, orig_stype, new_stype, span=span, ctx=ctx) if orig_stype.is_tuple(ctx.env.schema): return _cast_tuple( - ir_set, orig_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, orig_stype, new_stype, span=span, ctx=ctx) if isinstance(orig_stype, s_types.Array): if not s_types.is_type_compatible( @@ -178,7 +178,7 @@ def compile_cast( ir_set, el_type, orig_stype, ctx=ctx) return _cast_array( - ir_set, orig_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, orig_stype, new_stype, span=span, ctx=ctx) if isinstance(orig_stype, s_types.Range): if s_types.is_type_compatible( @@ -203,7 +203,7 @@ def compile_cast( ir_set, orig_stype, mr_stype, cardinality_mod=cardinality_mod, ctx=ctx) return _cast_multirange( - ir_set, mr_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, mr_stype, new_stype, span=span, ctx=ctx) else: # The subtypes match, so this is a direct upcast from @@ -213,7 +213,7 @@ def compile_cast( cardinality_mod=cardinality_mod, ctx=ctx) return _cast_range( - ir_set, orig_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, orig_stype, new_stype, span=span, ctx=ctx) if orig_stype.is_multirange(): if s_types.is_type_compatible( @@ -225,7 +225,7 @@ def compile_cast( return ir_set else: return _cast_multirange( - ir_set, orig_stype, new_stype, srcctx=span, ctx=ctx) + ir_set, orig_stype, new_stype, span=span, ctx=ctx) if orig_stype.issubclass(ctx.env.schema, new_stype): # The new type is a supertype of the old type, @@ -295,7 +295,7 @@ def compile_cast( orig_stype, new_stype, cardinality_mod, - srcctx=span, + span=span, ctx=ctx, ) @@ -305,7 +305,7 @@ def compile_cast( orig_stype, new_stype, cardinality_mod, - srcctx=span, + span=span, ctx=ctx, ) @@ -315,7 +315,7 @@ def compile_cast( orig_stype, new_stype, cardinality_mod, - srcctx=span, + span=span, ctx=ctx, ) @@ -342,7 +342,7 @@ def compile_cast( orig_stype, new_stype, cardinality_mod=cardinality_mod, - srcctx=span, + span=span, ctx=ctx, ) @@ -382,19 +382,19 @@ def _compile_cast( ir_expr: Union[irast.Set, irast.Expr], orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel, cardinality_mod: Optional[qlast.CardinalityModifier]) -> irast.Set: ir_set = setgen.ensure_set(ir_expr, ctx=ctx) - cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) if cast is None: raise errors.QueryError( f'cannot cast ' f'{orig_stype.get_displayname(ctx.env.schema)!r} to ' f'{new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx or ir_set.span) + span=span or ir_set.span) return _cast_to_ir(ir_set, cast, orig_stype, new_stype, cardinality_mod, ctx=ctx) @@ -560,7 +560,7 @@ def get_abstract(self, schema: s_schema.Schema) -> bool: def _find_cast( orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> Optional[s_casts.Cast]: # Don't try to pick up casts when there is a direct subtyping @@ -596,7 +596,7 @@ def _find_cast( f'cannot unambiguously cast ' f'{orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) else: return None @@ -607,7 +607,7 @@ def _cast_json_to_tuple( new_stype: s_types.Tuple, cardinality_mod: Optional[qlast.CardinalityModifier], *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: with ctx.new() as subctx: @@ -652,7 +652,7 @@ def _cast_json_to_tuple( val = compile_cast( val, new_st, cardinality_mod=qlast.CardinalityModifier.Required, - ctx=subctx, span=srcctx) + ctx=subctx, span=span) elements.append(irast.TupleElement(name=new_el_name, val=val)) @@ -667,7 +667,7 @@ def _cast_tuple( ir_set: irast.Set, orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: assert isinstance(orig_stype, s_types.Tuple) @@ -677,7 +677,7 @@ def _cast_tuple( # the tuple indirections. pathctx.register_set_in_scope(ir_set, ctx=ctx) - direct_cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + direct_cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) orig_subtypes = dict(orig_stype.iter_subtypes(ctx.env.schema)) if direct_cast is not None: @@ -695,7 +695,7 @@ def _cast_tuple( ) val_type = setgen.get_set_type(val, ctx=ctx) # Element cast - val = compile_cast(val, new_stype, ctx=ctx, span=srcctx) + val = compile_cast(val, new_stype, ctx=ctx, span=span) elements.append(irast.TupleElement(name=n, val=val)) @@ -712,7 +712,7 @@ def _cast_tuple( raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) assert isinstance(new_stype, s_types.Tuple) new_subtypes = list(new_stype.iter_subtypes(ctx.env.schema)) @@ -721,7 +721,7 @@ def _cast_tuple( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}: ' f'the number of elements is not the same', - span=srcctx) + span=span) # For tuple-to-tuple casts we generate a new tuple # to simplify things on sqlgen side. @@ -737,7 +737,7 @@ def _cast_tuple( new_el_name, new_st = new_subtypes[i] if val_type != new_st: # Element cast - val = compile_cast(val, new_st, ctx=ctx, span=srcctx) + val = compile_cast(val, new_st, ctx=ctx, span=span) elements.append(irast.TupleElement(name=new_el_name, val=val)) @@ -752,12 +752,12 @@ def _cast_range( ir_set: irast.Set, orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: assert isinstance(orig_stype, s_types.Range) - direct_cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + direct_cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) if direct_cast is not None: return _cast_to_ir( ir_set, direct_cast, orig_stype, new_stype, ctx=ctx @@ -767,18 +767,18 @@ def _cast_range( raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) assert isinstance(new_stype, s_types.Range) el_type = new_stype.get_subtypes(ctx.env.schema)[0] orig_el_type = orig_stype.get_subtypes(ctx.env.schema)[0] ql_el_type = typegen.type_to_ql_typeref(el_type, ctx=ctx) - el_cast = _find_cast(orig_el_type, el_type, srcctx=srcctx, ctx=ctx) + el_cast = _find_cast(orig_el_type, el_type, span=span, ctx=ctx) if el_cast is None: raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) with ctx.new() as subctx: subctx.anchors = subctx.anchors.copy() @@ -828,12 +828,12 @@ def _cast_multirange( ir_set: irast.Set, orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: assert isinstance(orig_stype, s_types.MultiRange) - direct_cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + direct_cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) if direct_cast is not None: return _cast_to_ir( ir_set, direct_cast, orig_stype, new_stype, ctx=ctx @@ -843,17 +843,17 @@ def _cast_multirange( raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) assert isinstance(new_stype, s_types.MultiRange) el_type = new_stype.get_subtypes(ctx.env.schema)[0] orig_el_type = orig_stype.get_subtypes(ctx.env.schema)[0] - el_cast = _find_cast(orig_el_type, el_type, srcctx=srcctx, ctx=ctx) + el_cast = _find_cast(orig_el_type, el_type, span=span, ctx=ctx) if el_cast is None: raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) ctx.env.schema, new_range_type = s_types.Range.from_subtypes( ctx.env.schema, [el_type]) @@ -897,7 +897,7 @@ def _cast_json_to_range( new_stype: s_types.Range, cardinality_mod: Optional[qlast.CardinalityModifier], *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: with ctx.new() as subctx: @@ -1005,7 +1005,7 @@ def _cast_json_to_multirange( new_stype: s_types.MultiRange, cardinality_mod: Optional[qlast.CardinalityModifier], *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: ctx.env.schema, new_range_type = s_types.Range.from_subtypes( @@ -1054,19 +1054,19 @@ def _cast_array( ir_set: irast.Set, orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: assert isinstance(orig_stype, s_types.Array) - direct_cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + direct_cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) if direct_cast is None: if not new_stype.is_array(): raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) + span=span) assert isinstance(new_stype, s_types.Array) el_type = new_stype.get_subtypes(ctx.env.schema)[0] elif new_stype.is_json(ctx.env.schema): @@ -1079,7 +1079,7 @@ def _cast_array( orig_el_type = orig_stype.get_subtypes(ctx.env.schema)[0] - el_cast = _find_cast(orig_el_type, el_type, srcctx=srcctx, ctx=ctx) + el_cast = _find_cast(orig_el_type, el_type, span=span, ctx=ctx) if el_cast is not None and el_cast.get_from_cast(ctx.env.schema): # Simple cast @@ -1155,21 +1155,21 @@ def _cast_array_literal( ir_set: irast.Set, orig_stype: s_types.Type, new_stype: s_types.Type, *, - srcctx: Optional[parsing.Span], + span: Optional[parsing.Span], ctx: context.ContextLevel) -> irast.Set: assert isinstance(ir_set.expr, irast.Array) orig_typeref = typegen.type_to_typeref(orig_stype, env=ctx.env) new_typeref = typegen.type_to_typeref(new_stype, env=ctx.env) - direct_cast = _find_cast(orig_stype, new_stype, srcctx=srcctx, ctx=ctx) + direct_cast = _find_cast(orig_stype, new_stype, span=span, ctx=ctx) if direct_cast is None: if not new_stype.is_array(): raise errors.QueryError( f'cannot cast {orig_stype.get_displayname(ctx.env.schema)!r} ' f'to {new_stype.get_displayname(ctx.env.schema)!r}', - span=srcctx) from None + span=span) from None assert isinstance(new_stype, s_types.Array) el_type = new_stype.get_subtypes(ctx.env.schema)[0] intermediate_stype = orig_stype @@ -1185,7 +1185,7 @@ def _cast_array_literal( for el in ir_set.expr.elements: el = compile_cast(el, el_type, cardinality_mod=qlast.CardinalityModifier.Required, - ctx=ctx, span=srcctx) + ctx=ctx, span=span) casted_els.append(el) new_array = setgen.ensure_set( diff --git a/edb/edgeql/compiler/expr.py b/edb/edgeql/compiler/expr.py index 28389e5b3de..a661654e36c 100644 --- a/edb/edgeql/compiler/expr.py +++ b/edb/edgeql/compiler/expr.py @@ -770,7 +770,7 @@ def compile_TypeCast( def _infer_type_introspection( typeref: irast.TypeRef, env: context.Environment, - srcctx: Optional[parsing.Span]=None, + span: Optional[parsing.Span]=None, ) -> s_types.Type: if irtyputils.is_scalar(typeref): return cast(s_objtypes.ObjectType, @@ -792,7 +792,7 @@ def _infer_type_introspection( env.schema.get('schema::MultiRange')) else: raise errors.QueryError( - 'unexpected type in INTROSPECT', span=srcctx) + 'unexpected type in INTROSPECT', span=span) @dispatch.compile.register(qlast.Introspect) diff --git a/edb/edgeql/compiler/func.py b/edb/edgeql/compiler/func.py index 6ff2b90a292..f76f81b7565 100644 --- a/edb/edgeql/compiler/func.py +++ b/edb/edgeql/compiler/func.py @@ -788,7 +788,7 @@ def get_globals( and not ctx.env.options.json_parameters ): glob_set = setgen.get_globals_as_json( - tuple(globs), ctx=ctx, srcctx=expr.span) + tuple(globs), ctx=ctx, span=expr.span) else: if ctx.env.options.func_params is not None: # Make sure that we properly track the globals we use in functions diff --git a/edb/edgeql/compiler/schemactx.py b/edb/edgeql/compiler/schemactx.py index 03b7b7de437..426406b2a5f 100644 --- a/edb/edgeql/compiler/schemactx.py +++ b/edb/edgeql/compiler/schemactx.py @@ -138,13 +138,13 @@ def get_schema_type( label: Optional[str] = None, condition: Optional[Callable[[s_obj.Object], bool]] = None, item_type: Optional[Type[s_obj.Object]] = None, - srcctx: Optional[parsing.Span] = None, + span: Optional[parsing.Span] = None, ) -> s_types.Type: if item_type is None: item_type = s_types.Type obj = get_schema_object(name, module, item_type=item_type, condition=condition, label=label, - ctx=ctx, span=srcctx) + ctx=ctx, span=span) assert isinstance(obj, s_types.Type) return obj diff --git a/edb/edgeql/compiler/setgen.py b/edb/edgeql/compiler/setgen.py index bfb1a2c6192..ea8051604ba 100644 --- a/edb/edgeql/compiler/setgen.py +++ b/edb/edgeql/compiler/setgen.py @@ -614,7 +614,8 @@ def compile_path(expr: qlast.Path, *, ctx: context.ContextLevel) -> irast.Set: subctx.path_scope = scope assert ir_set.rptr is not None comp_ir_set = computable_ptr_set( - ir_set.rptr, ir_set.path_id, srcctx=ir_set.span, ctx=subctx) + ir_set.expr, ir_set.path_id, span=ir_set.span, ctx=subctx + ) i = path_sets.index(ir_set) if i != len(path_sets) - 1: prptr = path_sets[i + 1].rptr @@ -651,7 +652,7 @@ def resolve_name( ), label='object type or alias', item_type=s_types.QualifiedType, - srcctx=name.span, + span=name.span, ctx=ctx, ) return (None, stype) @@ -942,7 +943,7 @@ def resolve_ptr_with_intersections( def _check_secret_ptr( ptrcls: s_pointers.Pointer, *, - srcctx: Optional[qlast.Span]=None, + span: Optional[qlast.Span]=None, ctx: context.ContextLevel, ) -> None: module = ptrcls.get_name(ctx.env.schema).module @@ -963,7 +964,7 @@ def _check_secret_ptr( vn = ptrcls.get_verbosename(ctx.env.schema, with_parent=True) raise errors.QueryError( f"cannot access {vn} because it is secret", - span=srcctx, + span=span, ) @@ -1019,7 +1020,7 @@ def extend_path( ) if ptrcls.get_secret(ctx.env.schema): - _check_secret_ptr(ptrcls, srcctx=span, ctx=ctx) + _check_secret_ptr(ptrcls, span=span, ctx=ctx) target = orig_ptrcls.get_far_endpoint(ctx.env.schema, direction) assert isinstance(target, s_types.Type) @@ -1040,7 +1041,7 @@ def extend_path( ptr, path_id, same_computable_scope=same_computable_scope, - srcctx=span, + span=span, ctx=ctx, ) @@ -1408,7 +1409,7 @@ def ensure_set( type_override: Optional[s_types.Type]=None, typehint: Optional[s_types.Type]=None, path_id: Optional[irast.PathId]=None, - srcctx: Optional[qlast.Span]=None, + span: Optional[qlast.Span]=None, ctx: context.ContextLevel) -> irast.Set: if not isinstance(expr, irast.Set): @@ -1425,8 +1426,8 @@ def ensure_set( stype = type_override - if srcctx is not None: - ir_set = new_set_from_set(ir_set, span=srcctx, ctx=ctx) + if span is not None: + ir_set = new_set_from_set(ir_set, span=span, ctx=ctx) if (isinstance(ir_set, irast.EmptySet) and (stype is None or stype.is_any(ctx.env.schema)) @@ -1494,7 +1495,7 @@ def computable_ptr_set( path_id: irast.PathId, *, same_computable_scope: bool=False, - srcctx: Optional[qlast.Span]=None, + span: Optional[qlast.Span]=None, ctx: context.ContextLevel, ) -> irast.Set: """Return ir.Set for a pointer defined as a computable.""" @@ -1646,7 +1647,7 @@ def computable_ptr_set( # XXX: or should we update rptr in place?? rptr = rptr.replace(expr=comp_ir_set.expr) comp_ir_set = new_set_from_set( - comp_ir_set, path_id=path_id, expr=rptr, span=srcctx, + comp_ir_set, path_id=path_id, expr=rptr, span=span, merge_current_ns=True, ctx=ctx) @@ -2070,7 +2071,7 @@ def get_func_global_param_sets( def get_globals_as_json( globs: Sequence[s_globals.Global], *, ctx: context.ContextLevel, - srcctx: Optional[qlast.Span], + span: Optional[qlast.Span], ) -> irast.Set: """Build a json object that contains the values of `globs` @@ -2099,7 +2100,7 @@ def get_globals_as_json( raise errors.SchemaDefinitionError( f'functions that reference global variables cannot be called ' f'from {typname}', - span=srcctx) + span=span) null_expr = qlast.FunctionCall( func=('__std__', 'to_json'), diff --git a/edb/edgeql/compiler/viewgen.py b/edb/edgeql/compiler/viewgen.py index 7cba99bee42..ca08fa16a8e 100644 --- a/edb/edgeql/compiler/viewgen.py +++ b/edb/edgeql/compiler/viewgen.py @@ -2433,15 +2433,15 @@ def _late_compile_view_shapes_in_set( shape = [] for path_tip, ptr, shape_op, _ in shape_ptrs: - srcctx = None + span = None if ptr in ctx.env.pointer_specified_info: - _, _, srcctx = ctx.env.pointer_specified_info[ptr] + _, _, span = ctx.env.pointer_specified_info[ptr] element = setgen.extend_path( path_tip, ptr, same_computable_scope=True, - span=srcctx, + span=span, ctx=ctx, ) diff --git a/edb/ir/staeval.py b/edb/ir/staeval.py index bf75f012c28..b67425f0d32 100644 --- a/edb/ir/staeval.py +++ b/edb/ir/staeval.py @@ -178,7 +178,7 @@ def _process_op_result( typeref: irast.TypeRef, schema: s_schema.Schema, *, - srcctx: Optional[parsing.Span]=None, + span: Optional[parsing.Span]=None, ) -> irast.ConstExpr: qlconst: qlast.BaseConstant if isinstance(value, str): @@ -187,7 +187,7 @@ def _process_op_result( qlconst = qlast.BooleanConstant.from_python(value) else: raise UnsupportedExpressionError( - f"unsupported result type: {type(value)}", span=srcctx + f"unsupported result type: {type(value)}", span=span ) result = qlcompiler.compile_constant_tree_to_ir( @@ -241,7 +241,7 @@ def evaluate_OperatorCall( value = eval_func(*args) return _process_op_result( - value, opcall.typeref, schema, srcctx=opcall.span) + value, opcall.typeref, schema, span=opcall.span) @evaluate.register(irast.SliceIndirection) @@ -271,7 +271,7 @@ def evaluate_SliceIndirection( value = base[start:stop] return _process_op_result( - value, slice.expr.typeref, schema, srcctx=slice.span) + value, slice.expr.typeref, schema, span=slice.span) def _evaluate_union( diff --git a/edb/pgsql/compiler/expr.py b/edb/pgsql/compiler/expr.py index c7a94437452..ce8f7574269 100644 --- a/edb/pgsql/compiler/expr.py +++ b/edb/pgsql/compiler/expr.py @@ -264,7 +264,7 @@ def compile_IndexIndirection( # line, column and filename are captured here to be used with the # error message - srcctx = pgast.StringConstant( + span = pgast.StringConstant( val=irutils.get_span_as_json( expr.index, errors.InvalidValueError ) @@ -277,7 +277,7 @@ def compile_IndexIndirection( result = pgast.FuncCall( name=('edgedb', '_index'), - args=[subj, index, srcctx] + args=[subj, index, span] ) return result diff --git a/edb/schema/functions.py b/edb/schema/functions.py index b58bec31462..ac5ce312131 100644 --- a/edb/schema/functions.py +++ b/edb/schema/functions.py @@ -1340,7 +1340,7 @@ def find_object_param_overloads( self, schema: s_schema.Schema, *, - srcctx: Optional[parsing.Span] = None, + span: Optional[parsing.Span] = None, ) -> Optional[Tuple[List[Function], int]]: """Find if this function overloads another in object parameter. @@ -1417,7 +1417,7 @@ def find_object_param_overloads( f'overloading an object type-receiving ' f'function with differences in the remaining ' f'parameters is not supported', - span=srcctx, + span=span, details=( f"Other function is defined as `{other_sig}`" ) @@ -1437,7 +1437,7 @@ def find_object_param_overloads( f'function: overloading an object type-receiving ' f'function with differences in the names of ' f'parameters is not supported', - span=srcctx, + span=span, details=( f"Other function is defined as `{other_sig}`" ) @@ -1457,7 +1457,7 @@ def find_object_param_overloads( f'function: overloading an object type-receiving ' f'function with differences in the type modifiers of ' f'parameters is not supported', - span=srcctx, + span=span, details=( f"Other function is defined as `{other_sig}`" ) @@ -1473,7 +1473,7 @@ def find_object_param_overloads( f'object type-receiving ' f'functions may not be overloaded on an OPTIONAL ' f'parameter', - span=srcctx, + span=span, ) diff_param = this_diff_param @@ -1887,7 +1887,7 @@ def _create_begin( if has_objects: self.scls.find_object_param_overloads( - schema, srcctx=self.span) + schema, span=self.span) if has_from_function: # Ignore the generic fallback when considering diff --git a/edb/schema/globals.py b/edb/schema/globals.py index ef452077dcb..24e2d7b2416 100644 --- a/edb/schema/globals.py +++ b/edb/schema/globals.py @@ -148,26 +148,26 @@ def _check_expr( glob_name = self.get_verbosename() if spec_required and not required: - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'possibly an empty set returned by an ' f'expression for the computed ' f'{glob_name} ' f"explicitly declared as 'required'", - span=srcctx + span=span ) if ( spec_card is qltypes.SchemaCardinality.One and card is not qltypes.SchemaCardinality.One ): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'possibly more than one element returned by an ' f'expression for the computed ' f'{glob_name} ' f"explicitly declared as 'single'", - span=srcctx + span=span ) if spec_card is None: diff --git a/edb/schema/inheriting.py b/edb/schema/inheriting.py index 936d0a20e86..380a607d92a 100644 --- a/edb/schema/inheriting.py +++ b/edb/schema/inheriting.py @@ -141,8 +141,8 @@ def inherit_fields( schema=schema, ) except errors.SchemaDefinitionError as e: - if (srcctx := self.get_attribute_span(field_name)): - e.set_span(srcctx) + if (span := self.get_attribute_span(field_name)): + e.set_span(span) raise if not ignore_local_field: diff --git a/edb/schema/links.py b/edb/schema/links.py index 4a4447eed08..905114ee002 100644 --- a/edb/schema/links.py +++ b/edb/schema/links.py @@ -261,7 +261,7 @@ def validate_object( assert target is not None if not target.is_object_type(): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') if isinstance(target, s_types.Array): # Custom error message for link -> array<...> link_dn = scls.get_displayname(schema) @@ -273,15 +273,15 @@ def validate_object( raise errors.InvalidLinkTargetError( f'invalid link target type, expected object type, got ' f'{target.get_verbosename(schema)}', - span=srcctx, + span=span, hint=hint, ) if target.is_free_object_type(schema): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.InvalidLinkTargetError( f'{target.get_verbosename(schema)} is not a valid link target', - span=srcctx, + span=span, ) if ( @@ -289,11 +289,11 @@ def validate_object( and not scls.get_from_alias(schema) and target.is_view(schema) ): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.InvalidLinkTargetError( f'invalid link type: {target.get_displayname(schema)!r}' f' is an expression alias, not a proper object type', - span=srcctx, + span=span, ) if ( diff --git a/edb/schema/pointers.py b/edb/schema/pointers.py index 77e12f70ab4..300018242a0 100644 --- a/edb/schema/pointers.py +++ b/edb/schema/pointers.py @@ -1200,11 +1200,11 @@ def canonicalize_attributes( inf_target_ref = None if inf_target_ref is not None: - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') self.set_attribute_value( 'target', inf_target_ref, - span=srcctx, + span=span, computed=True, ) @@ -1329,12 +1329,12 @@ def _parse_computable( # and best to consistently give an understandable error. for schema_ref in expression.irast.schema_refs: if isinstance(schema_ref, s_expraliases.Alias): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') an = schema_ref.get_verbosename(expression.irast.schema) raise errors.UnsupportedFeatureError( f'referring to {an} from computed {ptr_name} ' f'is unsupported', - span=srcctx, + span=span, ) if ( @@ -1377,37 +1377,37 @@ def _parse_computable( expression.irast.schema) if spec_target_type != inferred_target_type: - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'the type inferred from the expression ' f'of the computed {ptr_name} ' f'is {inferred_target_type.get_verbosename(mschema)}, ' f'which does not match the explicitly specified ' f'{spec_target_type.get_verbosename(schema)}', - span=srcctx + span=span ) if spec_required and not required: - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'possibly an empty set returned by an ' f'expression for the computed ' f'{ptr_name} ' f"explicitly declared as 'required'", - span=srcctx + span=span ) if ( spec_card is qltypes.SchemaCardinality.One and card is not qltypes.SchemaCardinality.One ): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'possibly more than one element returned by an ' f'expression for the computed ' f'{ptr_name} ' f"explicitly declared as 'single'", - span=srcctx + span=span ) if spec_card is None: @@ -1420,11 +1420,11 @@ def _parse_computable( not is_view_source(source, schema) and expression.irast.volatility == qltypes.Volatility.Volatile ): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.SchemaDefinitionError( f'volatile functions are not permitted in schema-defined ' f'computed expressions', - span=srcctx + span=span ) self.set_attribute_value('computable', True) diff --git a/edb/schema/policies.py b/edb/schema/policies.py index 09615e71d80..07726471b12 100644 --- a/edb/schema/policies.py +++ b/edb/schema/policies.py @@ -162,33 +162,33 @@ def canonicalize_attributes( value=expr, ) - srcctx = self.get_attribute_span(field) + span = self.get_attribute_span(field) if expression.irast.cardinality.can_be_zero(): raise errors.SchemaDefinitionError( f'possibly an empty set returned by {vname} ' f'expression for the {pol_name} ', - span=srcctx + span=span ) if expression.irast.cardinality.is_multi(): raise errors.SchemaDefinitionError( f'possibly more than one element returned by {vname} ' f'expression for the {pol_name} ', - span=srcctx + span=span ) if expression.irast.volatility.is_volatile(): raise errors.SchemaDefinitionError( f'{pol_name} has a volatile {vname} expression, ' f'which is not allowed', - span=srcctx + span=span ) target = schema.get(sn.QualName('std', 'bool'), type=s_types.Type) expr_type = expression.irast.stype if not expr_type.issubclass(expression.irast.schema, target): - srcctx = self.get_attribute_span(field) + span = self.get_attribute_span(field) raise errors.SchemaDefinitionError( f'{vname} expression for {pol_name} is of invalid type: ' f'{expr_type.get_displayname(schema)}, ' diff --git a/edb/schema/properties.py b/edb/schema/properties.py index c490c728f3f..8ba219294b0 100644 --- a/edb/schema/properties.py +++ b/edb/schema/properties.py @@ -257,23 +257,23 @@ def validate_object( raise TypeError(f'missing target type in scls {scls}') if target_type.is_polymorphic(schema): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.InvalidPropertyTargetError( f'invalid property type: ' f'{target_type.get_verbosename(schema)} ' f'is a generic type', - span=srcctx, + span=span, ) if (target_type.is_object_type() or (isinstance(target_type, s_types.Collection) and target_type.contains_object(schema))): - srcctx = self.get_attribute_span('target') + span = self.get_attribute_span('target') raise errors.InvalidPropertyTargetError( f'invalid property type: expected a scalar type, ' f'or a scalar collection, got ' f'{target_type.get_verbosename(schema)}', - span=srcctx, + span=span, ) def _check_linkprop_errors(self, node: qlast.DDLOperation) -> None: diff --git a/edb/schema/triggers.py b/edb/schema/triggers.py index 4cc0550a3dd..cf6d7104af2 100644 --- a/edb/schema/triggers.py +++ b/edb/schema/triggers.py @@ -149,13 +149,13 @@ def canonicalize_attributes( sn.QualName('std', 'bool'), type=s_types.Type) expr_type = expression.irast.stype if not expr_type.issubclass(expression.irast.schema, target): - srcctx = self.get_attribute_span(field) + span = self.get_attribute_span(field) raise errors.SchemaDefinitionError( f'{vname} expression for {trig_name} is of invalid ' f'type: ' f'{expr_type.get_displayname(schema)}, ' f'expected {target.get_displayname(schema)}', - span=srcctx, + span=span, ) if expression.irast.dml_exprs: diff --git a/edb/schema/types.py b/edb/schema/types.py index bbfb2cea354..b079e4a1d60 100644 --- a/edb/schema/types.py +++ b/edb/schema/types.py @@ -3417,14 +3417,14 @@ def materialize_type_in_attribute( if type_ref is None: return schema - srcctx = cmd.get_attribute_span('target') + span = cmd.get_attribute_span('target') if isinstance(type_ref, TypeExprShell): cc_cmd = ensure_schema_type_expr_type( schema, type_ref, parent_cmd=cmd, - span=srcctx, + span=span, context=context, ) if cc_cmd is not None: @@ -3453,11 +3453,11 @@ def materialize_type_in_attribute( modaliases=context.modaliases, schema=schema, item_type=Type, - span=srcctx, + span=span, ) raise except errors.InvalidPropertyDefinitionError as e: - e.set_span(srcctx) + e.set_span(span) raise elif not isinstance(type_ref, Type): raise AssertionError(