SPPCompiler.SemanticAnalysis.Utils.SemanticError module

exception SPPCompiler.SemanticAnalysis.Utils.SemanticError.SemanticError(*args)

Bases: BaseException

class Format(*values)

Bases: Enum

NORMAL = 0
MINIMAL = 1
NONE = 2
class ErrorInfo(ast, tag, msg, tip, fmt)

Bases: object

ast: Asts.Ast
tag: str
msg: str
tip: str
fmt: SemanticError.Format
error_formatters: list[ErrorFormatter]
error_info: list[ErrorInfo]
abstractmethod add(*args, **kwargs)
Return type:

SemanticError

scopes(*scopes)
Return type:

SemanticError

add_error(ast, tag, msg, tip, fmt=Format.NORMAL)
Return type:

SemanticError

add_info(ast, tag)
Return type:

SemanticError

throw()
Return type:

NoReturn

class SPPCompiler.SemanticAnalysis.Utils.SemanticError.SemanticErrors

Bases: object

exception AnnotationInvalidLocationError(*args)

Bases: SemanticError

The AnnotationInvalidLocationError is raised if a standard annotation is applied to a non-compatible AST. This includes applying the “@public” annotation to a superimposition, or the “@no_impl” method annotation to a class. An allowlist of valid ASTs for the annotation is provided in the error message.

add(annotation, applied_to, block_list)
Return type:

SemanticError

exception AnnotationInvalidError(*args)

Bases: SemanticError

The AnnotationInvalidError is raised if a non-standard annotation is used in the code. This includes using the “@foo” annotation, which is not a valid annotation in the language. Only standard annotations are allowed, such as “@public”, “@no_impl” etc.

add(annotation)
Return type:

SemanticError

exception AnnotationConflictError(*args)

Bases: SemanticError

The AnnotationConflictError is raised if there are 2 annotations on the same object that either have conflicting behaviour / are mutually exclusive. For example, using “@hot” and “@cold” on the same function would raise this error.

add(first_annotation, conflicting_annotation)
Return type:

SemanticError

exception IdentifierDuplicationError(*args)

Bases: SemanticError

The IdentifierDuplicationError is raised if the same identifier is defined multiple times in the same context. This could be for class attributes, function parameter names, generic parameter names etc.

add(first_occurrence, second_occurrence, what)
Return type:

SemanticError

exception OrderInvalidError(*args)

Bases: SemanticError

The OrderInvalidError is raised if a collection of ASTs is in the wrong order. This includes optional parameters before required parameters, or named arguments before unnamed arguments.

add(first_what, first, second_what, second, what)
Return type:

SemanticError

exception ParameterMultipleSelfError(*args)

Bases: SemanticError

The ParameterMultipleSelfError is raised if there are multiple “self” parameters in a function definition. A maximum one “self” parameter is allowed per function.

add(first_self_parameter, second_self_parameter)
Return type:

SemanticError

exception ParameterSelfOutsideSuperimpositionError(*args)

Bases: SemanticError

The ParameterSelfOutsideSuperimpositionError is raised if a “self” parameter is used outside of a superimposition, ie in a module-level free function.

add(self_parameter, function)
Return type:

SemanticError

exception ParameterMultipleVariadicError(*args)

Bases: SemanticError

The ParameterMultipleVariadicError is raised if there are multiple variadic parameters in a function definition. A maximum one variadic parameter is allowed per function.

add(first_variadic_parameter, second_variadic_parameter)
Return type:

SemanticError

exception FunctionCoroutineInvalidReturnTypeError(*args)

Bases: SemanticError

The FunctionCoroutineInvalidReturnTypeError is raised if a coroutine has a return type that is not a generator. All coroutines must return Gen[T] (with optional generic type parameters).

add(return_type)
Return type:

SemanticError

exception FunctionCoroutineContainsReturnStatementError(*args)

Bases: SemanticError

The FunctionCoroutineContainsRetError is raised if a coroutine contains a return statement with an expression. Coroutines cannot contain “ret” statements with expressions, only empty “ret” statements or “gen” expressions, which yield a value. The actual generator is implicitly returned as soon as the function is called.

add(coroutine_definition, expression)
Return type:

SemanticError

exception FunctionSubroutineContainsGenExpressionError(*args)

Bases: SemanticError

The FunctionSubroutineContainsGenError is raised if a subroutine contains a “gen” expression. Subroutines cannot contain “gen” expressions, only “ret” statements, which return a value.

add(subroutine_definition, gen_expression)
Return type:

SemanticError

exception FunctionSubroutineMissingReturnStatementError(*args)

Bases: SemanticError

The FunctionSubroutineMissingRetError is raised if a non-void-returning subroutine does not contain a return statement.

add(final_member, return_type)
Return type:

SemanticError

exception FunctionPrototypeConflictError(*args)

Bases: SemanticError

The FunctionPrototypeConflictError is raised if there are multiple function prototypes with an equal signature. There are certain criteria such as conventions and parameter types that have to match for a function to be considered a duplicate.

add(first_prototype, second_prototype)
Return type:

SemanticError

exception ArgumentNameInvalidError(*args)

Bases: SemanticError

The ArgumentNameInvalidError is raised if a named argument has been provided with a name that is not valid based on the target. This would be parameter vs argument name or attribute vs object initialization argument name. The source is the parameter/attribute, and the target is the argument.

add(target, what_target, source, what_source)
Return type:

SemanticError

exception ArgumentRequiredNameMissingError(*args)

Bases: SemanticError

The ArgumentRequiredNameMissingError is raised if a required named argument is missing from a function call or object initialization. This would be a parameter vs argument name or attribute vs object initialization argument name. The source is the parameter/attribute, and the target is the argument.

add(where, target, what_target, what_source)
Return type:

SemanticError

exception ArgumentTupleExpansionOfNonTupleError(*args)

Bases: SemanticError

The ArgumentTupleExpansionOfNonTupleError is raised if a tuple expansion is used on a non-tuple type. Tuple expansions can only be used on tuples, such as “f(..tuple_argument)”.

add(expansion_arg, arg_type)
Return type:

SemanticError

exception FunctionCallNoValidSignaturesError(*args)

Bases: SemanticError

The FunctionCallNoValidSignaturesError is raised if a function call has no valid signatures that match the arguments provided. A list of valid signatures is provided in the error message.

add(function_call, signatures, attempted)
Return type:

SemanticError

exception GenericArgumentTooManyError(*args)

Bases: SemanticError

The GenericArgumentTooManyError is raised if a function call has too many generic arguments. This can be from a type definition, or a function call.

add(generic_parameters, owner, extra_generic_argument)
Return type:

SemanticError

exception GenericArgumentIncorrectVariationError(*args)

Bases: SemanticError

The GenericParameterIncorrectVariationError is raised if a generic type argument is used to match a generic comp parameter or vice versa.

add(generic_parameter, generic_argument, owner)
Return type:

SemanticError

exception FunctionCallAmbiguousSignaturesError(*args)

Bases: SemanticError

The FunctionCallAmbiguousSignaturesError is raised if a function call has multiple valid signatures that match the arguments provided. This is caused by generic substitution causing a match with multiple overloads. Concrete types signature conflicts are detected on function prototype analysis.

add(function_call, signatures, attempted)
Return type:

SemanticError

exception FunctionCallAbstractFunctionError(*args)

Bases: SemanticError

The FunctionCallAbstractFunctionError is raised if an abstract function is called. Abstract functions cannot be called directly, as they have no implementation. Instead, they must be called on a subtype that provides an implementation.

add(function, function_call)
Return type:

SemanticError

exception FunctionCallTooManyArgumentsError(*args)

Bases: SemanticError

The FunctionCallTooManyArgumentsError is raised if a function call has too many arguments. Todo: add more info?

add(function_call, function_definition)
Return type:

SemanticError

exception UnreachableCodeError(*args)

Bases: SemanticError

The UnreachableCodeError is raised if there is code after a skip/exit/ret keyword in the same scope. This code is unreachable as the keyword always exits the scope into the parent scope.

add(return_ast, next_ast)
Return type:

SemanticError

exception NumberOutOfBoundsError(*args)

Bases: SemanticError

The NumberOutOfBoundsError is raised if a number is out of the valid range for the type. This includes integer literals that are too large or too small, and float literals that are too large or too small.

add(number, minimum, maximum, what)
Return type:

SemanticError

exception IdentifierUnknownError(*args)

Bases: SemanticError

The IdentifierUnknownError is raised if an identifier is used that is not defined in the current scope. This could be a variable, attribute, namespace, type etc.

add(identifier, what, closest_match)
Return type:

SemanticError

exception AmbiguousMemberAccessError(*args)

Bases: SemanticError

The AmbiguousMemberAccessError is raised if a member access is ambiguous, meaning that there are multiple members with the same name at the highest level. For example, if A inherits from B and C, and both B and C define the attribute “x”, then accessing “A.x” would be ambiguous, as it is not clear which “x” is being accessed. But if A also has an “x” attribute, then it is clear that “A.x” refers to A’s own “x” attribute.

add(first, second, field)
Return type:

SemanticError

exception TypeVoidInvalidUsageError(*args)

Bases: SemanticError

The TypeVoidInvalidUsageError is raised if the void type is used in an invalid context. The void type cannot be used as a variable type, function return type, function parameter type etc.

add(type)
Return type:

SemanticError

exception TypeMismatchError(*args)

Bases: SemanticError

The TypeMismatchError is raised if 2 types are different when they should not be. This could be in a variable assignment, function call, function return type etc.

Todo: add potential alias’s old type: (… aka: …)

add(existing_ast, existing_type, incoming_ast, incoming_type)
Return type:

SemanticError

exception YieldedTypeMismatchError(*args)

Bases: SemanticError

The YieldedTypeMismatchError is raised if 2 types are different when they should not be, in a yielding context. This is a separate error from TypeMismatchError, as it contains extra information about the yielding context.

add(existing_ast, existing_type, incoming_ast, incoming_type, is_optional, is_fallible, error_type)
Return type:

SemanticError

exception GenericParameterNotInferredError(*args)

Bases: SemanticError

The GenericParameterNotInferredError is raised if a generic parameter is not inferred from its caller context. Inference comes from arguments.

add(generic_parameter_name, caller_context)
Return type:

SemanticError

exception GenericParameterInferredConflictInferredError(*args)

Bases: SemanticError

The GenericParameterInferenceConflictError is raised if a generic parameter is inferred from multiple contexts, with different types. For example, “f[T](a: T, b: T)” called as “f(1, true)” would infer T as both BigInt and Bool.

add(generic_parameter_name, inferred_1, inferred_2)
Return type:

SemanticError

exception GenericParameterInferredConflictExplicitError(*args)

Bases: SemanticError

The GenericParameterInferencePassesExplicitlyError is raised if a generic parameter is inferred from its caller context, but is also passed explicitly. This is redundant and should be removed. For example, “f[T](a: T)” being called as “f[Bool](true)” contains the redundant explicit generic argument, even if the type is correct.

add(generic_parameter_name, explicit, inferred)
Return type:

SemanticError

exception GenericTypeInvalidUsageError(*args)

Bases: SemanticError

The GenericTypeInvalidUsageError is raised if a generic type is used in an invalid context. An example would be trying to initialize a generic type.

add(generic_value, generic_type, context)
Return type:

SemanticError

exception ArrayElementsDifferentTypesError(*args)

Bases: SemanticError

The ArrayElementsDifferentTypesError is raised if the elements of an array have different types. All elements in an array must have the same type.

add(element_ast_1, element_type_1, element_ast_2, element_type_2)
Return type:

SemanticError

exception ArrayElementBorrowedError(*args)

Bases: SemanticError

The ArrayElementBorrowedError is raised if an element in an array is borrowed. Array elements cannot be borrowed, and must all be owned.

add(element, borrow_location)
Return type:

SemanticError

exception MemoryInconsistentlyInitializedError(*args)

Bases: SemanticError

The MemoryInconsistentlyInitializedError is raised if a memory symbol is inconsistently initialized in different branches of the code. This could be a move in one branch and not in another.

add(ast, branch_1, branch_2, what)
Return type:

SemanticError

exception MemoryInconsistentlyPinnedError(*args)

Bases: SemanticError

The MemoryInconsistentlyPinnedError is raised if a memory symbol is inconsistently pinned in different branches of the code. This could be pinned in one branch and not in another.

add(ast, branch_1, branch_2)
Return type:

SemanticError

exception MemoryNotInitializedUsageError(*args)

Bases: SemanticError

The MemoryNotInitializedUsageError is raised if a memory symbol is used before it is initialized / after it has been moved.

add(init_location, ast, move_location, sm)
Return type:

SemanticError

exception MemoryPartiallyInitializedUsageError(*args)

Bases: SemanticError

The MemoryPartiallyInitializedUsageError is raised if a memory symbol is used before it is fully initialized. Partially initialized objects have missing attributes.

add(ast, partial_move_location)
Return type:

SemanticError

exception MemoryMovedFromBorrowedContextError(*args)

Bases: SemanticError

The MemoryMovedFromBorrowedContextError is raised if a memory symbol is moved from a borrowed context. This occurs when a attribute is moved of a &T type or a method consumes an attribute of the T type.

add(move_location, borrow_location)
Return type:

SemanticError

exception MemoryMovedWhilstLinkPinnedError(*args)

Bases: SemanticError

The MemoryMovedWhilstLinkPinnedError is raised if a memory symbol is moved whilst it is pinned by another symbol. This occurs when for example a coroutine is moved, but is pinned by a borrow passed into it.

add(move_location, symbol_initialization, pin_location, pin_initialization)
Return type:

SemanticError

exception MemoryMovedWhilstPinnedError(*args)

Bases: SemanticError

The MemoryMovedWhilstPinnedError is raised if a memory symbol is moved whilst it is pinned. This occurs when for example an owned object is moved, but is pinned as a borrow into a coroutine.

add(move_location, symbol_initialization, pin_location)
Return type:

SemanticError

exception MemoryOverlapUsageError(*args)

Bases: SemanticError

The MemoryOverlapUsageError is raised if a memory symbol is used whilst it overlaps with another memory symbol. This occurs when in a function call such as “f(a.b, a.b.c)” where “a.b” and “a.b.c” overlap.

add(overlap, ast)
Return type:

SemanticError

exception MutabilityInvalidMutationError(*args)

Bases: SemanticError

The MutabilityInvalidMutationError is raised if an immutable symbol is mutated. This occurs when a symbol is defined as immutable “let x = 4” and then mutated “x = 5”.

add(ast, move_location, immutable_definition)
Return type:

SemanticError

exception AssignmentInvalidLhsError(*args)

Bases: SemanticError

The AssignmentInvalidLhsError is raised if the left-hand-side of an assignment is invalid. For example “1 = 2” would be an invalid assignment as the left-hand-side is a literal.

add(lhs)
Return type:

SemanticError

exception AssignmentInvalidCompoundLhsError(*args)

Bases: SemanticError

The AssignmentInvalidCompoundLhsError is raised if the left-hand-side of a compound assignment is invalid. For example “1 += 2” would be an invalid compound assignment as the left-hand-side is a literal.

add(lhs)
Return type:

SemanticError

exception ExpressionTypeInvalidError(*args)

Bases: SemanticError

The ExpressionTypeInvalidError is raised if an expression is of an invalid AST. For example, types can be used as the lhs of a postfix member access (“Type::static_method()”), but not as an argument for example “f(Type)”.

add(expression)
Return type:

SemanticError

exception ExpressionNotBooleanError(*args)

Bases: SemanticError

The ExpressionNotBooleanError is raised if an expression is not a boolean type when it is expected to be. This could be in a conditional statement, a loop condition etc.

add(expression, type, what)
Return type:

SemanticError

exception ExpressionNotGeneratorError(*args)

Bases: SemanticError

The ExpressionNotGeneratorError is raised if an expression is not a generator type when it is expected to be. This is when using “generator.next()” expressions.

add(expression, type, what)
Return type:

SemanticError

exception MemberAccessStaticOperatorExpectedError(*args)

Bases: SemanticError

The MemberAccessStaticOperatorExpectedError is raised if a static member access is expected, but a runtime member access is found. Static member access uses “::” and runtime member access uses “.”.

add(lhs, access_token)
Return type:

SemanticError

exception MemberAccessRuntimeOperatorExpectedError(*args)

Bases: SemanticError

The MemberAccessRuntimeOperatorExpectedError is raised if a runtime member access is expected, but a static member access is found. Static member access uses “::” and runtime member access uses “.”.

add(lhs, access_token)
Return type:

SemanticError

exception MemberAccessNonIndexableError(*args)

Bases: SemanticError

The MemberAccessNonIndexableError is raised if a member access is performed on a non-indexable type. For example, “let x = 5” followed by “x.4” would raise this error.

add(lhs, lhs_type, access_token)
Return type:

SemanticError

exception MemberAccessIndexOutOfBoundsError(*args)

Bases: SemanticError

The MemberAccessIndexOutOfBoundsError is raised if a member access is out of bounds for the type. For example, accessing the 4th element of a 3-tuple.

add(lhs, lhs_type, number_token)
Return type:

SemanticError

exception SuperimpositionGenericNamedArgumentError(*args)

Bases: SemanticError

The SuperimpositionGenericNamedArgumentError is raised if a named argument is used in a superimposition. Superimpositions must match their class signature. For example, “sup [T, U] Point[T, U]” is fine, but “sup [A, B] Point[T=A, U=B]” is not.

add(named_argument)
Return type:

SemanticError

exception SuperimpositionGenericArgumentMismatchError(*args)

Bases: SemanticError

The SuperimpositionGenericArgumentMismatchError is raised if a generic argument is mismatched in a superimposition. For the “cls Point[T, U]” type, the superimposition must look like “sup [T, U] Point[T, U]”.

add(generic_argument, superimposition)
Return type:

SemanticError

exception SuperimpositionExtensionMethodInvalidError(*args)

Bases: SemanticError

The SuperimpositionExtensionMethodInvalidError is raised if a subclass method does not exist on the superclass. The signature of the superclass method and subclass method must match exactly.

add(new_method, super_class)
Return type:

SemanticError

exception SuperimpositionExtensionUseStatementInvalidError(*args)

Bases: SemanticError

The SuperimpositionExtensionUseStatementInvalidError is raised if a subclass “use” statement does not exist on the superclass. Any associated type on an extension must belong to the superclass as-well.

add(new_use_statement, super_class)
Return type:

SemanticError

exception SuperimpositionExtensionCmpStatementInvalidError(*args)

Bases: SemanticError

The SuperimpositionExtensionCmpStatementInvalidError is raised if a subclass “cmp” statement does not exist on the superclass. Any associated type on an extension must belong to the superclass as-well.

add(new_cmp_statement, super_class)
Return type:

SemanticError

exception SuperimpositionExtensionNonVirtualMethodOverriddenError(*args)

Bases: SemanticError

The SuperimpositionExtensionNonVirtualMethodOverriddenError is raised if a non-virtual method on the base class is overridden in the subclass. Non-virtual methods cannot be overridden.

add(base_method, super_class)
Return type:

SemanticError

exception SuperimpositionExtensionDuplicateSuperclassError(*args)

Bases: SemanticError

The SuperimpositionExtensionDuplicateSuperclassError is raised if a type is superimposed twice over another type. The 2 matched types are symbolically equal, ie alias-aware, generically matched types.

add(first_extension, second_extension)
Return type:

SemanticError

exception SuperimpositionExtensionCyclicExtensionError(*args)

Bases: SemanticError

The SuperimpositionExtensionCyclicSuperclassError is raised two types extend each other. Extension trees, whilst supporting multi-parents, must be loop free.

add(first_extension, second_extension)
Return type:

SemanticError

exception SuperimpositionExtensionSelfExtensionError(*args)

Bases: SemanticError

The SuperimpositionExtensionSelfExtensionError is raised if a type extends itself. This is not allowed, as it would create an infinite loop in the extension tree.

add(extension)
Return type:

SemanticError

exception SuperimpositionUnconstrainedGenericParameterError(*args)

Bases: SemanticError

The SuperimpositionUnconstrainedGenericParameterError is raised if a generic parameter is unconstrained in a superimposition. All generic parameters must be constrained to the overridden type, as there is no way to pass a generic argument into a superimposition. Same as “non-inferrable” generic parameters.

add(unconstrained_generic_parameter, type)
Return type:

SemanticError

exception SuperimpositionOptionalGenericParameterError(*args)

Bases: SemanticError

The SuperimpositionOptionalGenericParameterError is raised if a generic parameter is optional in a superimposition. As all generic parameters are inferrable in a superimposition, they cannot be optional.

add(optional_generic_parameter)
Return type:

SemanticError

exception LoopTooManyControlFlowStatementsError(*args)

Bases: SemanticError

The LoopTooManyControlFlowStatementsError is raised if a loop has too many control flow statements. The maximum number of control flow statements is equal to the loop depth.

add(loop, loop_control, number_of_controls, depth_of_loop)
Return type:

SemanticError

exception TupleElementBorrowedError(*args)

Bases: SemanticError

The TupleElementBorrowedError is raised if an element in a tuple is borrowed. Array elements cannot be borrowed, and must all be owned.

add(element, borrow_location)
Return type:

SemanticError

exception CaseBranchesConflictingTypesError(*args)

Bases: SemanticError

The CaseBranchesConflictingTypesError is raised if the branches in a case statement return conflicting types, and the case expression is being used for assignment.

add(return_type_1, return_type_2)
Return type:

SemanticError

exception CaseBranchesMissingElseBranchError(*args)

Bases: SemanticError

The CaseBranchesMissingElseBranchError is raised if a case statement is missing an else branch, and the case expression is being used for assignment.

add(condition, final_branch)
Return type:

SemanticError

exception CaseBranchesElseBranchNotLastError(*args)

Bases: SemanticError

The CaseBranchesElseBranchNotLastError is raised if the else branch is not the last branch in a case statement.

add(else_branch, last_branch)
Return type:

SemanticError

exception CaseBranchMultipleDestructurePatternsError(*args)

Bases: SemanticError

The CaseBranchMultipleDestructurePatternsError is raised if a case branch has multiple destructure patterns. A case branch can only have one destructure pattern.

add(first_pattern, second_pattern)
Return type:

SemanticError

exception VariableDestructureContainsMultipleMultiSkipsError(*args)

Bases: SemanticError

The VariableDestructureContainsMultipleMultiSkipsError is raised if a variable destructure contains multiple multi-skips. A maximum of one multi-skip is allowed per destructure. The destructure “let (.., a, ..) = x” is invalid.

add(first_multi_skip, second_multi_skip)
Return type:

SemanticError

exception VariableObjectDestructureWithBoundMultiSkipError(*args)

Bases: SemanticError

The VariableObjectDestructureWithBoundMultiSkipError is raised if a variable object-destructure contains a multi-skip with a binding. For example, “let Point(x, y, ..) = p” is fine, but “let Point(..values) = p” is invalid.

add(object_destructure, bound_multi_skip)
Return type:

SemanticError

exception VariableTupleDestructureTupleSizeMismatchError(*args)

Bases: SemanticError

The VariableTupleDestructureTupleSizeMismatchError is raised if a variable tuple-destructure has a different number of elements than the tuple being destructured. For example, “let (a, b) = (1, 2, 3)” is invalid.

add(lhs, lhs_count, rhs, rhs_count)
Return type:

SemanticError

exception VariableTupleDestructureTupleTypeMismatchError(*args)

Bases: SemanticError

The VariableTupleDestructureTupleTypeMismatchError is raised if a tuple-destructure on a non-tuple type is attempted. It is a more specialized TypeMismatchError.

add(destructure, rhs, rhs_type)
Return type:

SemanticError

exception VariableArrayDestructureArraySizeMismatchError(*args)

Bases: SemanticError

The VariableArrayDestructureArraySizeMismatchError is raised if a variable array-destructure has a different number of elements than the array being destructured. For example, “let [a, b] = [1, 2, 3]” is invalid.

add(lhs, lhs_count, rhs, rhs_count)
Return type:

SemanticError

exception VariableArrayDestructureArrayTypeMismatchError(*args)

Bases: SemanticError

The VariableTupleDestructureArrayTypeMismatchError is raised if an array-destructure on a non-array type is attempted. It is a more specialized TypeMismatchError.

add(destructure, rhs, rhs_type)
Return type:

SemanticError

exception AsyncFunctionCallInvalidTargetError(*args)

Bases: SemanticError

The AsyncFunctionCallInvalidTargetError is raised if the target of an async function call is not a function. For example, whilst “async f()” is valid, “async 5” is not.

add(async_modifier, target)
Return type:

SemanticError

exception ObjectInitializerMultipleDefArgumentsError(*args)

Bases: SemanticError

The ObjectInitializerMultipleDefArgumentsError is raised if an object initializer has multiple default arguments. Only one default argument is allowed. For example, “Type(else=a, else=b)” is invalid”.

add(first_else, second_else)
Return type:

SemanticError

exception ObjectInitializerGenericWithArgumentsError(*args)

Bases: SemanticError

An ObjectInitializerGenericWithArgumentsError error is raised if a generic type is being initialized (valid), but with arguments. This is invalid because generic types have different attributes. So only full default initialization can be used (no arguments).

add(generic_type, argument)
Return type:

SemanticError

exception InvalidObjectInitializerArgumentError(*args)

Bases: SemanticError

The InvalidObjectInitializerArgumentError is raised if an object initializer argument is unnamed and not an identifier. Without this error, the parser assumes a function call, which leads to weird errors if the lhs type is generic.

add(argument)
Return type:

SemanticError

exception RecursiveTypeDefinitionError(*args)

Bases: SemanticError

The RecursiveTypeDefinitionError is raised if a type definition is recursive. This is when a type definition refers to itself in its own definition, as an attribute, making the type an infinite size.

add(class_prototype, recursion_type)
Return type:

SemanticError

exception InvalidConventionLocationError(*args)

Bases: SemanticError

The InvalidConventionLocationError is raised if a type has been declared with a convention, somewhere where a convention is not allowed. This includes attributes, return types etc.

add(convention, location, what)
Return type:

SemanticError

exception InvalidSelfTypeError(*args)

Bases: SemanticError

The InvalidSelfTypeError is raised if an arbitrary type passed to a self parameter does not superimpose the “Deref[Self]” type. This is because all “self” parameters must be either be “Self”, with the inclusion of dereferencing to “Self”.

add(type)
Return type:

SemanticError

exception InvalidTypeAnnotationError(*args)

Bases: SemanticError

The InvalidTypeAnnotationError is raised if a type annotation is given to a “let” statement when the LHS isn’t a single identifier. This is because in a destructuring context, giving a type isn’t allowed as multiple types will be created from the symbols introduced.

add(type, local_variable)
Return type:

SemanticError

exception UseStatementInvalidGenericArgumentsError(*args)

Bases: SemanticError

The UseStatementInvalidGenericArgumentsError is raised is a “use” statement look lise “use std::vector[T]”. Instead, it should just be “use std::vector” or “use vector[T] = std::vector[T]”.

add(use_statement, generic_argument)
Return type:

SemanticError

exception FunctionFoldTupleElementTypeMismatchError(*args)

Bases: SemanticError

The FunctionFoldTupleElementTypeMismatchError is raised if a tuple being folded into a function has a different types in its elements. For example, “f((1, 2, 3))..” is valid, but “f((1, 2, “3”))..” is invalid, because there are BigInt and Str elements in the tuple.

add(first_type, mismatch)
Return type:

SemanticError

exception FunctionFoldTupleLengthMismatchError(*args)

Bases: SemanticError

The FunctionFoldTupleLengthMismatchError is raised if there are > 1 tuples being folded into a function call, and each tuple has a different number of elements.

add(first_tuple, first_tuple_length, second_tuple, second_tuple_length)
Return type:

SemanticError

exception MissingMainFunctionError(*args)

Bases: SemanticError

The MissingMainFunctionError is raised if the main function is missing from the program. The main function is the entry point and must match a certain signature.

add(main_module)
Return type:

SemanticError

exception InvalidFfiSppTypeError(*args)

Bases: SemanticError

The InvalidFfiSppTypeError is raised if a type is not a valid FFI type. This means it has to C ABI conversion, and therefore cannot be used for FFI.

add(type)
Return type:

SemanticError

exception InvalidFfiFunctionError(*args)

Bases: SemanticError

The InvalidFfiFunctionError is raised if a function is not a valid FFI function. This means it has to C ABI conversion, and therefore cannot be used for FFI.

add(function, dll)
Return type:

SemanticError

exception IterExpressionBranchMissingError(*args)

Bases: SemanticError

The IterExpressionBranchMissingError is raised if an iter expression block is missing a branch for a specific generator type, such as the “_” no-value branch got a GenOpt type.

add(condition, generator_type, block, missing_branch)
Return type:

SemanticError

exception IterExpressionBranchTypeDuplicateError(*args)

Bases: SemanticError

The IterExpressionBranchTypeDuplicateError is raised if an iter expression block has multiple branches with the same pattern type. For example, two branches with the same “IterPatternVariableAst” type.

add(branch, duplicate_branch)
Return type:

SemanticError

exception IterExpressionBranchIncompatibleError(*args)

Bases: SemanticError

The IterExpressionBranchIncompatibleError is raised if an iter expression block has a branch that is incompatible with the condition type. For example, a branch with an “IterPatternNoValueAst” type when the condition is not a GenRes type.

add(cond, cond_type, branch_pattern, expected_type)
Return type:

SemanticError

exception EarlyReturnRequiresTryTypeError(*args)

Bases: SemanticError

The EarlyReturnRequiresTryTypeError is raised if an early return is used with an expression whose type doesn’t superimpose the Try type. The Try type is needed to get the output argument (early return type).

add(op, expr, expr_type)
Return type:

SemanticError

exception InvalidDereferenceExpressionConvention(*args)

Bases: SemanticError

The InvalidDereferenceExpressionConvention error is raised if a dereference expression has an invalid expression convention; a dereference operation can only occur on borrow-convention types.

add(deref_tok, rhs, rhs_type)
Return type:

SemanticError

exception InvalidDereferenceExpressionType(*args)

Bases: SemanticError

The InvalidDereferenceExpressionType error is raised if a dereference expression has an invalid type; a dereference operation can only occur on a type that superimposes “Copy”.

add(deref_tok, rhs, rhs_type)
Return type:

SemanticError