From 46b2bb208845108ca9ff9a78260440aee994a194 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Wed, 3 Apr 2024 12:01:11 +0200 Subject: [PATCH] fix: error in Python generator for assignments with class/enum variant call as RHS (#977) Closes #975 ### Summary of Changes The code generator no longer throws a `RangeError: Invalid array length` for assignments that have a class or enum variant call as the right-hand-side. --- .../flow/safe-ds-call-graph-computer.ts | 2 +- .../generation/safe-ds-markdown-generator.ts | 2 +- .../generation/safe-ds-python-generator.ts | 11 ++-- .../language/helpers/safe-ds-node-mapper.ts | 2 +- .../lsp/safe-ds-inlay-hint-provider.ts | 2 +- .../lsp/safe-ds-node-info-provider.ts | 2 +- .../lsp/safe-ds-signature-help-provider.ts | 2 +- .../lsp/safe-ds-type-hierarchy-provider.ts | 2 +- .../src/language/safe-ds-module.ts | 4 +- .../scoping/safe-ds-scope-provider.ts | 4 +- .../safe-ds-lang/src/language/typing/model.ts | 16 +++--- .../language/typing/safe-ds-type-checker.ts | 6 +-- .../language/typing/safe-ds-type-computer.ts | 6 +-- .../src/language/validation/inheritance.ts | 10 ++-- .../other/declarations/parameterBounds.ts | 12 ++--- .../other/declarations/parameters.ts | 4 +- .../other/declarations/typeParameters.ts | 2 +- .../other/expressions/chainedExpressions.ts | 4 +- .../other/expressions/indexedAccess.ts | 4 +- .../other/expressions/infixOperations.ts | 6 +-- .../validation/other/types/unionTypes.ts | 2 +- .../src/language/validation/purity.ts | 8 +-- .../src/language/validation/style.ts | 8 +-- .../src/language/validation/types.ts | 50 +++++++++---------- .../tests/language/typing/model.test.ts | 4 +- .../typing/safe-ds-class-hierarchy.test.ts | 2 +- .../canBeTypeOfConstantParameter.test.ts | 8 +-- .../type checker/isSubOrSupertypeOf.test.ts | 8 +-- .../computeClassTypeForLiteralType.test.ts | 6 +-- .../type computer/computeUpperBound.test.ts | 4 +- .../safe-ds-type-computer.test.ts | 2 +- .../type computer/streamSupertypes.test.ts | 2 +- .../generator/assignment/main}/gen_input.py | 0 .../assignment/main}/gen_input.py.map | 0 .../main}/gen_input_testPipeline.py | 0 .../main}/input.sdstest | 2 +- .../assignment/rhsIsClassCall/gen_input.py | 4 ++ .../rhsIsClassCall/gen_input.py.map | 1 + .../rhsIsClassCall/gen_input_testPipeline.py | 4 ++ .../rhs is class call/input.sdstest | 9 ++++ .../rhsIsEnumVariantCall/gen_input.py | 4 ++ .../rhsIsEnumVariantCall/gen_input.py.map | 1 + .../gen_input_testPipeline.py | 4 ++ .../rhs is enum variant call/input.sdstest | 11 ++++ 44 files changed, 144 insertions(+), 103 deletions(-) rename packages/safe-ds-lang/tests/resources/generation/python/statements/{assignment/generated/tests/generator/assignment => assignments/main/generated/tests/generator/assignment/main}/gen_input.py (100%) rename packages/safe-ds-lang/tests/resources/generation/python/statements/{assignment/generated/tests/generator/assignment => assignments/main/generated/tests/generator/assignment/main}/gen_input.py.map (100%) rename packages/safe-ds-lang/tests/resources/generation/python/statements/{assignment/generated/tests/generator/assignment => assignments/main/generated/tests/generator/assignment/main}/gen_input_testPipeline.py (100%) rename packages/safe-ds-lang/tests/resources/generation/python/statements/{assignment => assignments/main}/input.sdstest (94%) create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py.map create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input_testPipeline.py create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/input.sdstest create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py.map create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input_testPipeline.py create mode 100644 packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/input.sdstest diff --git a/packages/safe-ds-lang/src/language/flow/safe-ds-call-graph-computer.ts b/packages/safe-ds-lang/src/language/flow/safe-ds-call-graph-computer.ts index aaa5e98b9..20f655e19 100644 --- a/packages/safe-ds-lang/src/language/flow/safe-ds-call-graph-computer.ts +++ b/packages/safe-ds-lang/src/language/flow/safe-ds-call-graph-computer.ts @@ -58,7 +58,7 @@ export class SafeDsCallGraphComputer { this.astNodeLocator = services.workspace.AstNodeLocator; this.nodeMapper = services.helpers.NodeMapper; this.partialEvaluator = services.evaluation.PartialEvaluator; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; this.callCache = new WorkspaceCache(services.shared); this.callGraphCache = new WorkspaceCache(services.shared); diff --git a/packages/safe-ds-lang/src/language/generation/safe-ds-markdown-generator.ts b/packages/safe-ds-lang/src/language/generation/safe-ds-markdown-generator.ts index 1f9547ef9..00f5a93dd 100644 --- a/packages/safe-ds-lang/src/language/generation/safe-ds-markdown-generator.ts +++ b/packages/safe-ds-lang/src/language/generation/safe-ds-markdown-generator.ts @@ -61,7 +61,7 @@ export class SafeDsMarkdownGenerator { constructor(services: SafeDsServices) { this.builtinAnnotations = services.builtins.Annotations; this.documentationProvider = services.documentation.DocumentationProvider; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; } generate(documents: LangiumDocument[], options: GenerateOptions): TextDocument[] { diff --git a/packages/safe-ds-lang/src/language/generation/safe-ds-python-generator.ts b/packages/safe-ds-lang/src/language/generation/safe-ds-python-generator.ts index c28d38adf..d2907a2d9 100644 --- a/packages/safe-ds-lang/src/language/generation/safe-ds-python-generator.ts +++ b/packages/safe-ds-lang/src/language/generation/safe-ds-python-generator.ts @@ -94,6 +94,8 @@ import { SafeDsPartialEvaluator } from '../partialEvaluation/safe-ds-partial-eva import { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsPurityComputer } from '../purity/safe-ds-purity-computer.js'; import { FileRead, ImpurityReason } from '../purity/model.js'; +import { SafeDsTypeComputer } from '../typing/safe-ds-type-computer.js'; +import { NamedTupleType } from '../typing/model.js'; export const CODEGEN_PREFIX = '__gen_'; const BLOCK_LAMBDA_PREFIX = `${CODEGEN_PREFIX}block_lambda_`; @@ -174,12 +176,14 @@ export class SafeDsPythonGenerator { private readonly nodeMapper: SafeDsNodeMapper; private readonly partialEvaluator: SafeDsPartialEvaluator; private readonly purityComputer: SafeDsPurityComputer; + private readonly typeComputer: SafeDsTypeComputer; constructor(services: SafeDsServices) { this.builtinAnnotations = services.builtins.Annotations; this.nodeMapper = services.helpers.NodeMapper; this.partialEvaluator = services.evaluation.PartialEvaluator; this.purityComputer = services.purity.PurityComputer; + this.typeComputer = services.typing.TypeComputer; } generate(document: LangiumDocument, options: GenerateOptions): TextDocument[] { @@ -616,10 +620,9 @@ export class SafeDsPythonGenerator { frame: GenerationInfoFrame, generateLambda: boolean, ): CompositeGeneratorNode { - const requiredAssignees = isSdsCall(assignment.expression) - ? getAbstractResults(this.nodeMapper.callToCallable(assignment.expression)).length - : /* c8 ignore next */ - 1; + const rhsType = this.typeComputer.computeType(assignment.expression); + const requiredAssignees = rhsType instanceof NamedTupleType ? rhsType.length : 1; + const assignees = getAssignees(assignment); if (assignees.some((value) => !isSdsWildcard(value))) { const actualAssignees = assignees.map(this.generateAssignee); diff --git a/packages/safe-ds-lang/src/language/helpers/safe-ds-node-mapper.ts b/packages/safe-ds-lang/src/language/helpers/safe-ds-node-mapper.ts index 97a1184ba..47a790ccd 100644 --- a/packages/safe-ds-lang/src/language/helpers/safe-ds-node-mapper.ts +++ b/packages/safe-ds-lang/src/language/helpers/safe-ds-node-mapper.ts @@ -46,7 +46,7 @@ export class SafeDsNodeMapper { private readonly typeComputer: () => SafeDsTypeComputer; constructor(services: SafeDsServices) { - this.typeComputer = () => services.types.TypeComputer; + this.typeComputer = () => services.typing.TypeComputer; } /** diff --git a/packages/safe-ds-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts b/packages/safe-ds-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts index 68ab4a7d8..2568c5ff7 100644 --- a/packages/safe-ds-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts +++ b/packages/safe-ds-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts @@ -19,7 +19,7 @@ export class SafeDsInlayHintProvider extends AbstractInlayHintProvider { this.documentationProvider = services.documentation.DocumentationProvider; this.nodeMapper = services.helpers.NodeMapper; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; } override computeInlayHint(node: AstNode, acceptor: InlayHintAcceptor) { diff --git a/packages/safe-ds-lang/src/language/lsp/safe-ds-node-info-provider.ts b/packages/safe-ds-lang/src/language/lsp/safe-ds-node-info-provider.ts index 8d6ca2cea..33227f646 100644 --- a/packages/safe-ds-lang/src/language/lsp/safe-ds-node-info-provider.ts +++ b/packages/safe-ds-lang/src/language/lsp/safe-ds-node-info-provider.ts @@ -11,7 +11,7 @@ export class SafeDsNodeInfoProvider { constructor(services: SafeDsServices) { this.builtinAnnotations = services.builtins.Annotations; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; } /** diff --git a/packages/safe-ds-lang/src/language/lsp/safe-ds-signature-help-provider.ts b/packages/safe-ds-lang/src/language/lsp/safe-ds-signature-help-provider.ts index cc0505c51..9e9aba204 100644 --- a/packages/safe-ds-lang/src/language/lsp/safe-ds-signature-help-provider.ts +++ b/packages/safe-ds-lang/src/language/lsp/safe-ds-signature-help-provider.ts @@ -31,7 +31,7 @@ export class SafeDsSignatureHelpProvider implements SignatureHelpProvider { constructor(services: SafeDsServices) { this.documentationProvider = services.documentation.DocumentationProvider; this.nodeMapper = services.helpers.NodeMapper; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; } provideSignatureHelp( diff --git a/packages/safe-ds-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts b/packages/safe-ds-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts index 3b8bf8f33..0b71479b6 100644 --- a/packages/safe-ds-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts +++ b/packages/safe-ds-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts @@ -22,7 +22,7 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { constructor(services: SafeDsServices) { super(services); - this.classHierarchy = services.types.ClassHierarchy; + this.classHierarchy = services.typing.ClassHierarchy; this.nodeKindProvider = services.shared.lsp.NodeKindProvider; this.nodeInfoProvider = services.lsp.NodeInfoProvider; } diff --git a/packages/safe-ds-lang/src/language/safe-ds-module.ts b/packages/safe-ds-lang/src/language/safe-ds-module.ts index cd7a9941c..58a7b4ecc 100644 --- a/packages/safe-ds-lang/src/language/safe-ds-module.ts +++ b/packages/safe-ds-lang/src/language/safe-ds-module.ts @@ -76,7 +76,7 @@ export type SafeDsAddedServices = { purity: { PurityComputer: SafeDsPurityComputer; }; - types: { + typing: { ClassHierarchy: SafeDsClassHierarchy; CoreTypes: SafeDsCoreTypes; TypeChecker: SafeDsTypeChecker; @@ -148,7 +148,7 @@ export const SafeDsModule: Module new SafeDsScopeComputation(services), ScopeProvider: (services) => new SafeDsScopeProvider(services), }, - types: { + typing: { ClassHierarchy: (services) => new SafeDsClassHierarchy(services), CoreTypes: (services) => new SafeDsCoreTypes(services), TypeChecker: (services) => new SafeDsTypeChecker(services), diff --git a/packages/safe-ds-lang/src/language/scoping/safe-ds-scope-provider.ts b/packages/safe-ds-lang/src/language/scoping/safe-ds-scope-provider.ts index 893402d3d..0f29ce249 100644 --- a/packages/safe-ds-lang/src/language/scoping/safe-ds-scope-provider.ts +++ b/packages/safe-ds-lang/src/language/scoping/safe-ds-scope-provider.ts @@ -90,10 +90,10 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { super(services); this.astReflection = services.shared.AstReflection; - this.classHierarchy = services.types.ClassHierarchy; + this.classHierarchy = services.typing.ClassHierarchy; this.nodeMapper = services.helpers.NodeMapper; this.packageManager = services.workspace.PackageManager; - this.typeComputer = services.types.TypeComputer; + this.typeComputer = services.typing.TypeComputer; this.coreDeclarationCache = new WorkspaceCache(services.shared); } diff --git a/packages/safe-ds-lang/src/language/typing/model.ts b/packages/safe-ds-lang/src/language/typing/model.ts index d9827ac94..d0c4a5bd4 100644 --- a/packages/safe-ds-lang/src/language/typing/model.ts +++ b/packages/safe-ds-lang/src/language/typing/model.ts @@ -78,7 +78,7 @@ export class CallableType extends Type { ) { super(); - this.factory = services.types.TypeFactory; + this.factory = services.typing.TypeFactory; } override get isFullySubstituted(): boolean { @@ -159,8 +159,8 @@ export class LiteralType extends Type { ) { super(); - this.coreTypes = services.types.CoreTypes; - this.factory = services.types.TypeFactory; + this.coreTypes = services.typing.CoreTypes; + this.factory = services.typing.TypeFactory; } override get isExplicitlyNullable(): boolean { @@ -242,7 +242,7 @@ export class NamedTupleType extends Type { constructor(services: SafeDsServices, entries: NamedTupleEntry[]) { super(); - this.factory = services.types.TypeFactory; + this.factory = services.typing.TypeFactory; this.entries = entries; } @@ -588,7 +588,7 @@ export class StaticType extends Type { ) { super(); - this.factory = services.types.TypeFactory; + this.factory = services.typing.TypeFactory; } override equals(other: unknown): boolean { @@ -636,9 +636,9 @@ export class UnionType extends Type { constructor(services: SafeDsServices, types: Type[]) { super(); - this.coreTypes = services.types.CoreTypes; - this.factory = services.types.TypeFactory; - this.typeChecker = services.types.TypeChecker; + this.coreTypes = services.typing.CoreTypes; + this.factory = services.typing.TypeFactory; + this.typeChecker = services.typing.TypeChecker; this.types = types; } diff --git a/packages/safe-ds-lang/src/language/typing/safe-ds-type-checker.ts b/packages/safe-ds-lang/src/language/typing/safe-ds-type-checker.ts index 3b99f0f09..155baef54 100644 --- a/packages/safe-ds-lang/src/language/typing/safe-ds-type-checker.ts +++ b/packages/safe-ds-lang/src/language/typing/safe-ds-type-checker.ts @@ -30,9 +30,9 @@ export class SafeDsTypeChecker { constructor(services: SafeDsServices) { this.builtinClasses = services.builtins.Classes; - this.classHierarchy = services.types.ClassHierarchy; - this.coreTypes = services.types.CoreTypes; - this.typeComputer = () => services.types.TypeComputer; + this.classHierarchy = services.typing.ClassHierarchy; + this.coreTypes = services.typing.CoreTypes; + this.typeComputer = () => services.typing.TypeComputer; } // ----------------------------------------------------------------------------------------------------------------- diff --git a/packages/safe-ds-lang/src/language/typing/safe-ds-type-computer.ts b/packages/safe-ds-lang/src/language/typing/safe-ds-type-computer.ts index c9f1a982b..737205c92 100644 --- a/packages/safe-ds-lang/src/language/typing/safe-ds-type-computer.ts +++ b/packages/safe-ds-lang/src/language/typing/safe-ds-type-computer.ts @@ -126,11 +126,11 @@ export class SafeDsTypeComputer { constructor(services: SafeDsServices) { this.astNodeLocator = services.workspace.AstNodeLocator; this.coreClasses = services.builtins.Classes; - this.coreTypes = services.types.CoreTypes; - this.factory = services.types.TypeFactory; + this.coreTypes = services.typing.CoreTypes; + this.factory = services.typing.TypeFactory; this.nodeMapper = services.helpers.NodeMapper; this.partialEvaluator = services.evaluation.PartialEvaluator; - this.typeChecker = services.types.TypeChecker; + this.typeChecker = services.typing.TypeChecker; this.nodeTypeCache = new WorkspaceCache(services.shared); } diff --git a/packages/safe-ds-lang/src/language/validation/inheritance.ts b/packages/safe-ds-lang/src/language/validation/inheritance.ts index dbe607080..d9932a180 100644 --- a/packages/safe-ds-lang/src/language/validation/inheritance.ts +++ b/packages/safe-ds-lang/src/language/validation/inheritance.ts @@ -16,9 +16,9 @@ export const CODE_INHERITANCE_NULLABLE = 'inheritance/nullable'; export const classMemberMustMatchOverriddenMemberAndShouldBeNeeded = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - const classHierarchy = services.types.ClassHierarchy; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const classHierarchy = services.typing.ClassHierarchy; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsClassMember, accept: ValidationAcceptor): void => { // Check whether the member overrides something @@ -151,7 +151,7 @@ const isInSafedsLangAnyClass = (services: SafeDsServices, node: SdsClassMember): }; export const classMustOnlyInheritASingleClass = (services: SafeDsServices) => { - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; const computeType = typeComputer.computeType.bind(typeComputer); return (node: SdsClass, accept: ValidationAcceptor): void => { @@ -189,7 +189,7 @@ export const classMustOnlyInheritASingleClass = (services: SafeDsServices) => { }; export const classMustNotInheritItself = (services: SafeDsServices) => { - const classHierarchy = services.types.ClassHierarchy; + const classHierarchy = services.typing.ClassHierarchy; return (node: SdsClass, accept: ValidationAcceptor): void => { const superClasses = classHierarchy.streamProperSuperclasses(node); diff --git a/packages/safe-ds-lang/src/language/validation/other/declarations/parameterBounds.ts b/packages/safe-ds-lang/src/language/validation/other/declarations/parameterBounds.ts index 6e2360aae..0057f7d68 100644 --- a/packages/safe-ds-lang/src/language/validation/other/declarations/parameterBounds.ts +++ b/packages/safe-ds-lang/src/language/validation/other/declarations/parameterBounds.ts @@ -130,9 +130,9 @@ const checkBound = ( }; export const parameterBoundParameterMustBeConstFloatOrInt = (services: SafeDsServices) => { - const coreTypes = services.types.CoreTypes; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const coreTypes = services.typing.CoreTypes; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsParameterBound, accept: ValidationAcceptor) => { const parameter = node.leftOperand?.ref; @@ -161,9 +161,9 @@ export const parameterBoundParameterMustBeConstFloatOrInt = (services: SafeDsSer }; export const parameterBoundRightOperandMustEvaluateToFloatConstantOrIntConstant = (services: SafeDsServices) => { - const coreTypes = services.types.CoreTypes; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const coreTypes = services.typing.CoreTypes; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; const partialEvaluator = services.evaluation.PartialEvaluator; const one = new IntConstant(1n); diff --git a/packages/safe-ds-lang/src/language/validation/other/declarations/parameters.ts b/packages/safe-ds-lang/src/language/validation/other/declarations/parameters.ts index b33d3bd4a..c0a09e745 100644 --- a/packages/safe-ds-lang/src/language/validation/other/declarations/parameters.ts +++ b/packages/safe-ds-lang/src/language/validation/other/declarations/parameters.ts @@ -28,8 +28,8 @@ export const constantParameterMustHaveConstantDefaultValue = (services: SafeDsSe }; export const constantParameterMustHaveTypeThatCanBeEvaluatedToConstant = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsParameter, accept: ValidationAcceptor) => { if (!Parameter.isConstant(node) || !node.type) { diff --git a/packages/safe-ds-lang/src/language/validation/other/declarations/typeParameters.ts b/packages/safe-ds-lang/src/language/validation/other/declarations/typeParameters.ts index a9f0b58ac..8ea8f13d6 100644 --- a/packages/safe-ds-lang/src/language/validation/other/declarations/typeParameters.ts +++ b/packages/safe-ds-lang/src/language/validation/other/declarations/typeParameters.ts @@ -62,7 +62,7 @@ export const typeParameterMustHaveSufficientContext = (node: SdsTypeParameter, a }; export const typeParameterUpperBoundMustBeNamedType = (services: SafeDsServices) => { - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsTypeParameter, accept: ValidationAcceptor) => { const boundType = typeComputer.computeType(node.upperBound); diff --git a/packages/safe-ds-lang/src/language/validation/other/expressions/chainedExpressions.ts b/packages/safe-ds-lang/src/language/validation/other/expressions/chainedExpressions.ts index e8880338f..b14d9d546 100644 --- a/packages/safe-ds-lang/src/language/validation/other/expressions/chainedExpressions.ts +++ b/packages/safe-ds-lang/src/language/validation/other/expressions/chainedExpressions.ts @@ -6,8 +6,8 @@ import { UnknownType } from '../../../typing/model.js'; export const CODE_CHAINED_EXPRESSION_MISSING_NULL_SAFETY = 'chained-expression/missing-null-safety'; export const chainedExpressionsMustBeNullSafeIfReceiverIsNullable = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsChainedExpression, accept: ValidationAcceptor): void => { if (node.isNullSafe) { diff --git a/packages/safe-ds-lang/src/language/validation/other/expressions/indexedAccess.ts b/packages/safe-ds-lang/src/language/validation/other/expressions/indexedAccess.ts index 678d9958e..ad881bc22 100644 --- a/packages/safe-ds-lang/src/language/validation/other/expressions/indexedAccess.ts +++ b/packages/safe-ds-lang/src/language/validation/other/expressions/indexedAccess.ts @@ -7,8 +7,8 @@ export const CODE_INDEXED_ACCESS_INVALID_INDEX = 'indexed-access/invalid-index'; export const indexedAccessIndexMustBeValid = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { const indexValue = partialEvaluator.evaluate(node.index); diff --git a/packages/safe-ds-lang/src/language/validation/other/expressions/infixOperations.ts b/packages/safe-ds-lang/src/language/validation/other/expressions/infixOperations.ts index 6457f0c3c..f4af2a3b0 100644 --- a/packages/safe-ds-lang/src/language/validation/other/expressions/infixOperations.ts +++ b/packages/safe-ds-lang/src/language/validation/other/expressions/infixOperations.ts @@ -7,10 +7,10 @@ import { UnknownType } from '../../../typing/model.js'; export const CODE_INFIX_OPERATION_DIVISION_BY_ZERO = 'infix-operation/division-by-zero'; export const divisionDivisorMustNotBeZero = (services: SafeDsServices) => { - const coreTypes = services.types.CoreTypes; + const coreTypes = services.typing.CoreTypes; const partialEvaluator = services.evaluation.PartialEvaluator; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; const zeroInt = new IntConstant(0n); const zeroFloat = new FloatConstant(0.0); diff --git a/packages/safe-ds-lang/src/language/validation/other/types/unionTypes.ts b/packages/safe-ds-lang/src/language/validation/other/types/unionTypes.ts index fa4b61735..cff99f90a 100644 --- a/packages/safe-ds-lang/src/language/validation/other/types/unionTypes.ts +++ b/packages/safe-ds-lang/src/language/validation/other/types/unionTypes.ts @@ -56,7 +56,7 @@ export const unionTypeMustHaveTypes = (node: SdsUnionType, accept: ValidationAcc }; export const unionTypeShouldNotHaveDuplicateTypes = (services: SafeDsServices) => { - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsUnionType, accept: ValidationAcceptor): void => { const typeArguments = getTypeArguments(node.typeArgumentList); diff --git a/packages/safe-ds-lang/src/language/validation/purity.ts b/packages/safe-ds-lang/src/language/validation/purity.ts index 7ba94e6e8..bb8461e9b 100644 --- a/packages/safe-ds-lang/src/language/validation/purity.ts +++ b/packages/safe-ds-lang/src/language/validation/purity.ts @@ -49,7 +49,7 @@ export const functionPurityMustBeSpecified = (services: SafeDsServices) => { export const impurityReasonsOfOverridingMethodMustBeSubsetOfOverriddenMethod = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - const classHierarchy = services.types.ClassHierarchy; + const classHierarchy = services.typing.ClassHierarchy; return (node: SdsFunction, accept: ValidationAcceptor): void => { const overriddenMember = classHierarchy.getOverriddenMember(node); @@ -93,7 +93,7 @@ export const impurityReasonParameterNameMustBelongToParameterOfCorrectType = (se const impurityReasons = services.builtins.ImpurityReasons; const nodeMapper = services.helpers.NodeMapper; const partialEvaluator = services.evaluation.PartialEvaluator; - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsFunction, accept: ValidationAcceptor) => { const annotationCall = findFirstAnnotationCallOf(node, builtinAnnotations.Impure); @@ -219,7 +219,7 @@ export const impurityReasonShouldNotBeSetMultipleTimes = (services: SafeDsServic export const pureParameterDefaultValueMustBePure = (services: SafeDsServices) => { const purityComputer = services.purity.PurityComputer; - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsParameter, accept: ValidationAcceptor) => { if (!node.defaultValue) { @@ -248,7 +248,7 @@ export const pureParameterDefaultValueMustBePure = (services: SafeDsServices) => export const callArgumentAssignedToPureParameterMustBePure = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; const purityComputer = services.purity.PurityComputer; - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsCall, accept: ValidationAcceptor) => { for (const argument of getArguments(node)) { diff --git a/packages/safe-ds-lang/src/language/validation/style.ts b/packages/safe-ds-lang/src/language/validation/style.ts index d0f9eb0f7..d308180f5 100644 --- a/packages/safe-ds-lang/src/language/validation/style.ts +++ b/packages/safe-ds-lang/src/language/validation/style.ts @@ -222,8 +222,8 @@ export const constraintListShouldNotBeEmpty = (services: SafeDsServices) => { export const elvisOperatorShouldBeNeeded = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; const settingsProvider = services.workspace.SettingsProvider; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return async (node: SdsInfixOperation, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { @@ -309,8 +309,8 @@ export const importedDeclarationAliasShouldDifferFromDeclarationName = (services export const chainedExpressionNullSafetyShouldBeNeeded = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return async (node: SdsChainedExpression, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { diff --git a/packages/safe-ds-lang/src/language/validation/types.ts b/packages/safe-ds-lang/src/language/validation/types.ts index c9c70a572..898e695f3 100644 --- a/packages/safe-ds-lang/src/language/validation/types.ts +++ b/packages/safe-ds-lang/src/language/validation/types.ts @@ -39,8 +39,8 @@ export const CODE_TYPE_MISSING_TYPE_HINT = 'type/missing-type-hint'; export const callArgumentTypesMustMatchParameterTypes = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsCall, accept: ValidationAcceptor) => { const substitutions = typeComputer.computeSubstitutionsForCall(node); @@ -99,8 +99,8 @@ export const callReceiverMustBeCallable = (services: SafeDsServices) => { }; export const indexedAccessReceiverMustBeListOrMap = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { if (!node.receiver) { @@ -120,9 +120,9 @@ export const indexedAccessReceiverMustBeListOrMap = (services: SafeDsServices) = export const indexedAccessIndexMustHaveCorrectType = (services: SafeDsServices) => { const coreClasses = services.builtins.Classes; - const coreTypes = services.types.CoreTypes; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const coreTypes = services.typing.CoreTypes; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { const receiverType = typeComputer.computeType(node.receiver); @@ -153,9 +153,9 @@ export const indexedAccessIndexMustHaveCorrectType = (services: SafeDsServices) }; export const infixOperationOperandsMustHaveCorrectType = (services: SafeDsServices) => { - const coreTypes = services.types.CoreTypes; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const coreTypes = services.typing.CoreTypes; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsInfixOperation, accept: ValidationAcceptor): void => { const leftType = typeComputer.computeType(node.leftOperand); @@ -214,7 +214,7 @@ export const infixOperationOperandsMustHaveCorrectType = (services: SafeDsServic }; export const listMustNotContainNamedTuples = (services: SafeDsServices) => { - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsList, accept: ValidationAcceptor): void => { for (const element of node.elements) { @@ -230,7 +230,7 @@ export const listMustNotContainNamedTuples = (services: SafeDsServices) => { }; export const mapMustNotContainNamedTuples = (services: SafeDsServices) => { - const typeComputer = services.types.TypeComputer; + const typeComputer = services.typing.TypeComputer; return (node: SdsMap, accept: ValidationAcceptor): void => { for (const entry of node.entries) { @@ -257,8 +257,8 @@ export const mapMustNotContainNamedTuples = (services: SafeDsServices) => { export const namedTypeTypeArgumentsMustMatchBounds = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsNamedType, accept: ValidationAcceptor): void => { const type = typeComputer.computeType(node); @@ -294,8 +294,8 @@ export const namedTypeTypeArgumentsMustMatchBounds = (services: SafeDsServices) }; export const parameterDefaultValueTypeMustMatchParameterType = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsParameter, accept: ValidationAcceptor) => { const defaultValue = node.defaultValue; @@ -317,9 +317,9 @@ export const parameterDefaultValueTypeMustMatchParameterType = (services: SafeDs }; export const prefixOperationOperandMustHaveCorrectType = (services: SafeDsServices) => { - const coreTypes = services.types.CoreTypes; - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const coreTypes = services.typing.CoreTypes; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsPrefixOperation, accept: ValidationAcceptor): void => { const operandType = typeComputer.computeType(node.operand); @@ -354,8 +354,8 @@ export const prefixOperationOperandMustHaveCorrectType = (services: SafeDsServic }; export const typeCastExpressionMustHaveUnknownType = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsTypeCast, accept: ValidationAcceptor): void => { const expressionType = typeComputer.computeType(node.expression); @@ -377,8 +377,8 @@ export const typeCastExpressionMustHaveUnknownType = (services: SafeDsServices) }; export const typeParameterDefaultValueMustMatchUpperBound = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsTypeParameter, accept: ValidationAcceptor): void => { if (!node.defaultValue || !node.upperBound) { @@ -399,8 +399,8 @@ export const typeParameterDefaultValueMustMatchUpperBound = (services: SafeDsSer }; export const yieldTypeMustMatchResultType = (services: SafeDsServices) => { - const typeChecker = services.types.TypeChecker; - const typeComputer = services.types.TypeComputer; + const typeChecker = services.typing.TypeChecker; + const typeComputer = services.typing.TypeComputer; return (node: SdsYield, accept: ValidationAcceptor) => { const result = node.result?.ref; diff --git a/packages/safe-ds-lang/tests/language/typing/model.test.ts b/packages/safe-ds-lang/tests/language/typing/model.test.ts index 518783a30..afece30f4 100644 --- a/packages/safe-ds-lang/tests/language/typing/model.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/model.test.ts @@ -18,8 +18,8 @@ import type { EqualsTest, ToStringTest } from '../../helpers/testDescription.js' import { expectEqualTypes } from '../../helpers/testAssertions.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const coreTypes = services.types.CoreTypes; -const factory = services.types.TypeFactory; +const coreTypes = services.typing.CoreTypes; +const factory = services.typing.TypeFactory; const code = ` fun f1(p1, p2: Int = 0) -> r diff --git a/packages/safe-ds-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts b/packages/safe-ds-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts index 766659551..182b8550e 100644 --- a/packages/safe-ds-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts @@ -12,7 +12,7 @@ import { getNodeOfType } from '../../helpers/nodeFinder.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; const builtinClasses = services.builtins.Classes; -const classHierarchy = services.types.ClassHierarchy; +const classHierarchy = services.typing.ClassHierarchy; describe('SafeDsClassHierarchy', async () => { describe('isEqualToOrSubclassOf', () => { diff --git a/packages/safe-ds-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts b/packages/safe-ds-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts index b07583d0a..5432ed456 100644 --- a/packages/safe-ds-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts @@ -6,10 +6,10 @@ import { ClassType, EnumType, EnumVariantType, Type, UnknownType } from '../../. import { getNodeOfType } from '../../../helpers/nodeFinder.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const coreTypes = services.types.CoreTypes; -const factory = services.types.TypeFactory; -const typeChecker = services.types.TypeChecker; -const typeComputer = services.types.TypeComputer; +const coreTypes = services.typing.CoreTypes; +const factory = services.typing.TypeFactory; +const typeChecker = services.typing.TypeChecker; +const typeComputer = services.typing.TypeComputer; const code = ` class MyClass diff --git a/packages/safe-ds-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts b/packages/safe-ds-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts index b182cac2c..4c4b56921 100644 --- a/packages/safe-ds-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts @@ -35,10 +35,10 @@ import { getNodeOfType } from '../../../helpers/nodeFinder.js'; import { AstUtils } from 'langium'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const coreTypes = services.types.CoreTypes; -const factory = services.types.TypeFactory; -const typeChecker = services.types.TypeChecker; -const typeComputer = services.types.TypeComputer; +const coreTypes = services.typing.CoreTypes; +const factory = services.typing.TypeFactory; +const typeChecker = services.typing.TypeChecker; +const typeComputer = services.typing.TypeComputer; const basic = async (): Promise => { const code = ` diff --git a/packages/safe-ds-lang/tests/language/typing/type computer/computeClassTypeForLiteralType.test.ts b/packages/safe-ds-lang/tests/language/typing/type computer/computeClassTypeForLiteralType.test.ts index eedecb292..840330275 100644 --- a/packages/safe-ds-lang/tests/language/typing/type computer/computeClassTypeForLiteralType.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type computer/computeClassTypeForLiteralType.test.ts @@ -12,9 +12,9 @@ import { expectEqualTypes } from '../../../helpers/testAssertions.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const coreTypes = services.types.CoreTypes; -const factory = services.types.TypeFactory; -const typeComputer = services.types.TypeComputer; +const coreTypes = services.typing.CoreTypes; +const factory = services.typing.TypeFactory; +const typeComputer = services.typing.TypeComputer; const tests: ComputeClassTypeForLiteralTypeTest[] = [ // Base cases diff --git a/packages/safe-ds-lang/tests/language/typing/type computer/computeUpperBound.test.ts b/packages/safe-ds-lang/tests/language/typing/type computer/computeUpperBound.test.ts index cce9a1e27..545b4aa35 100644 --- a/packages/safe-ds-lang/tests/language/typing/type computer/computeUpperBound.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type computer/computeUpperBound.test.ts @@ -7,8 +7,8 @@ import { getNodeOfType } from '../../../helpers/nodeFinder.js'; import { expectEqualTypes } from '../../../helpers/testAssertions.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const coreTypes = services.types.CoreTypes; -const typeComputer = services.types.TypeComputer; +const coreTypes = services.typing.CoreTypes; +const typeComputer = services.typing.TypeComputer; const code = ` class MyClass< diff --git a/packages/safe-ds-lang/tests/language/typing/type computer/safe-ds-type-computer.test.ts b/packages/safe-ds-lang/tests/language/typing/type computer/safe-ds-type-computer.test.ts index e69b125d4..945f663a9 100644 --- a/packages/safe-ds-lang/tests/language/typing/type computer/safe-ds-type-computer.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type computer/safe-ds-type-computer.test.ts @@ -8,7 +8,7 @@ import { loadDocuments } from '../../../helpers/testResources.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const typeComputer = services.types.TypeComputer; +const typeComputer = services.typing.TypeComputer; describe('typing', async () => { it.each(await createTypingTests())('$testName', async (test) => { diff --git a/packages/safe-ds-lang/tests/language/typing/type computer/streamSupertypes.test.ts b/packages/safe-ds-lang/tests/language/typing/type computer/streamSupertypes.test.ts index 8aab8e68c..c7f8ed0ab 100644 --- a/packages/safe-ds-lang/tests/language/typing/type computer/streamSupertypes.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/type computer/streamSupertypes.test.ts @@ -7,7 +7,7 @@ import { AssertionError } from 'assert'; import { createSafeDsServices } from '../../../../src/language/index.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const typeComputer = services.types.TypeComputer; +const typeComputer = services.typing.TypeComputer; describe('streamProperSupertypes', async () => { const properSupertypesAsStrings = (type: ClassType | undefined) => diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input.py similarity index 100% rename from packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input.py rename to packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input.py diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input.py.map similarity index 100% rename from packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input.py.map rename to packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input.py.map diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input_testPipeline.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input_testPipeline.py similarity index 100% rename from packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/generated/tests/generator/assignment/gen_input_testPipeline.py rename to packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/generated/tests/generator/assignment/main/gen_input_testPipeline.py diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/input.sdstest similarity index 94% rename from packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/input.sdstest rename to packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/input.sdstest index 1bcb70ae9..07b0917c9 100644 --- a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignment/input.sdstest +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/main/input.sdstest @@ -1,4 +1,4 @@ -package tests.generator.assignment +package tests.generator.assignment.main @Impure([ImpurityReason.Other]) fun f1(param: Any?) @Impure([ImpurityReason.PotentiallyImpureParameterCall("param")]) fun f2(param: () -> r: Int?) diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py new file mode 100644 index 000000000..8b2f913ff --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def testPipeline(): + a = MyClass1() diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py.map new file mode 100644 index 000000000..9dbae004c --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input.py.map @@ -0,0 +1 @@ +{"version":3,"sources":["input.sdstest"],"names":["testpipeline","myclass1"],"mappings":"AAEA;;AAIA,IAASA,YAAY;IACjB,IAAQC,QAAQ","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input_testPipeline.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input_testPipeline.py new file mode 100644 index 000000000..09ca75905 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/generated/tests/generator/assignment/rhsIsClassCall/gen_input_testPipeline.py @@ -0,0 +1,4 @@ +from .gen_input import testPipeline + +if __name__ == '__main__': + testPipeline() diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/input.sdstest new file mode 100644 index 000000000..a5a3be89c --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is class call/input.sdstest @@ -0,0 +1,9 @@ +// Related to https://github.com/Safe-DS/DSL/issues/975 + +package tests.generator.assignment.rhsIsClassCall + +class MyClass1() + +pipeline testPipeline { + val a = MyClass1(); +} diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py new file mode 100644 index 000000000..03cd89598 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def testPipeline(): + a = MyEnum1.MyEnumVariant1(1) diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py.map new file mode 100644 index 000000000..4166308ce --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input.py.map @@ -0,0 +1 @@ +{"version":3,"sources":["input.sdstest"],"names":["testpipeline","myenum1","myenumvariant1"],"mappings":"AAEA;;AAMA,IAASA,YAAY;IACjB,IAAQC,OAAO,CAACC,cAAc,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input_testPipeline.py b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input_testPipeline.py new file mode 100644 index 000000000..09ca75905 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/generated/tests/generator/assignment/rhsIsEnumVariantCall/gen_input_testPipeline.py @@ -0,0 +1,4 @@ +from .gen_input import testPipeline + +if __name__ == '__main__': + testPipeline() diff --git a/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/input.sdstest new file mode 100644 index 000000000..54e45e951 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/generation/python/statements/assignments/rhs is enum variant call/input.sdstest @@ -0,0 +1,11 @@ +// Related to https://github.com/Safe-DS/DSL/issues/975 + +package tests.generator.assignment.rhsIsEnumVariantCall + +enum MyEnum1 { + MyEnumVariant1(p: Int) +} + +pipeline testPipeline { + val a = MyEnum1.MyEnumVariant1(1); +}