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 d3dbe3ca8..70ff1dc3b 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 @@ -105,10 +105,7 @@ export class SafeDsTypeChecker { const typeEntry = type.outputType.entries[i]; const otherEntry = other.outputType.entries[i]; - // Names must match - if (typeEntry.name !== otherEntry.name) { - return false; - } + // Names must not match since we always fetch results by index // Types must be covariant if (!this.isAssignableTo(typeEntry.type, otherEntry.type)) { diff --git a/packages/safe-ds-lang/src/language/validation/safe-ds-validator.ts b/packages/safe-ds-lang/src/language/validation/safe-ds-validator.ts index ed7705395..0d950be89 100644 --- a/packages/safe-ds-lang/src/language/validation/safe-ds-validator.ts +++ b/packages/safe-ds-lang/src/language/validation/safe-ds-validator.ts @@ -44,11 +44,18 @@ import { yieldMustNotBeUsedInPipeline, } from './other/statements/assignments.js'; import { + argumentTypeMustMatchParameterType, attributeMustHaveTypeHint, callReceiverMustBeCallable, + indexedAccessIndexMustHaveCorrectType, + indexedAccessReceiverMustBeListOrMap, + infixOperationOperandsMustHaveCorrectType, namedTypeMustSetAllTypeParameters, + parameterDefaultValueTypeMustMatchParameterType, parameterMustHaveTypeHint, + prefixOperationOperandMustHaveCorrectType, resultMustHaveTypeHint, + yieldTypeMustMatchResultType, } from './types.js'; import { moduleDeclarationsMustMatchFileKind, @@ -182,6 +189,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsArgument: [ argumentCorrespondingParameterShouldNotBeDeprecated(services), argumentCorrespondingParameterShouldNotBeExperimental(services), + argumentTypeMustMatchParameterType(services), ], SdsArgumentList: [ argumentListMustNotHavePositionalArgumentsAfterNamedArguments, @@ -226,8 +234,16 @@ export const registerValidationChecks = function (services: SafeDsServices) { ], SdsImport: [importPackageMustExist(services), importPackageShouldNotBeEmpty(services)], SdsImportedDeclaration: [importedDeclarationAliasShouldDifferFromDeclarationName], - SdsIndexedAccess: [indexedAccessesShouldBeUsedWithCaution], - SdsInfixOperation: [divisionDivisorMustNotBeZero(services), elvisOperatorShouldBeNeeded(services)], + SdsIndexedAccess: [ + indexedAccessIndexMustHaveCorrectType(services), + indexedAccessReceiverMustBeListOrMap(services), + indexedAccessesShouldBeUsedWithCaution, + ], + SdsInfixOperation: [ + divisionDivisorMustNotBeZero(services), + elvisOperatorShouldBeNeeded(services), + infixOperationOperandsMustHaveCorrectType(services), + ], SdsLambda: [ lambdaMustBeAssignedToTypedParameter(services), lambdaParametersMustNotBeAnnotated, @@ -266,12 +282,14 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsParameter: [ constantParameterMustHaveConstantDefaultValue(services), parameterMustHaveTypeHint, + parameterDefaultValueTypeMustMatchParameterType(services), requiredParameterMustNotBeDeprecated(services), requiredParameterMustNotBeExpert(services), ], SdsParameterList: [parameterListMustNotHaveRequiredParametersAfterOptionalParameters], SdsPipeline: [pipelineMustContainUniqueNames], SdsPlaceholder: [placeholdersMustNotBeAnAlias, placeholderShouldBeUsed(services)], + SdsPrefixOperation: [prefixOperationOperandMustHaveCorrectType(services)], SdsReference: [ referenceMustNotBeFunctionPointer, referenceMustNotBeStaticClassOrEnumReference, @@ -299,7 +317,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { unionTypeShouldNotHaveDuplicateTypes(services), unionTypeShouldNotHaveASingularTypeArgument, ], - SdsYield: [yieldMustNotBeUsedInPipeline], + SdsYield: [yieldMustNotBeUsedInPipeline, yieldTypeMustMatchResultType(services)], }; registry.register(checks); }; diff --git a/packages/safe-ds-lang/src/language/validation/types.ts b/packages/safe-ds-lang/src/language/validation/types.ts index 974359d1a..b1fb4e5e2 100644 --- a/packages/safe-ds-lang/src/language/validation/types.ts +++ b/packages/safe-ds-lang/src/language/validation/types.ts @@ -8,11 +8,16 @@ import { isSdsPipeline, isSdsReference, isSdsSchema, + SdsArgument, SdsAttribute, SdsCall, + SdsIndexedAccess, + SdsInfixOperation, SdsNamedType, SdsParameter, + SdsPrefixOperation, SdsResult, + SdsYield, } from '../generated/ast.js'; import { getTypeArguments, getTypeParameters } from '../helpers/nodeProperties.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -20,6 +25,7 @@ import { pluralize } from '../../helpers/stringUtils.js'; import { isEmpty } from '../../helpers/collectionUtils.js'; export const CODE_TYPE_CALLABLE_RECEIVER = 'type/callable-receiver'; +export const CODE_TYPE_MISMATCH = 'type/mismatch'; export const CODE_TYPE_MISSING_TYPE_ARGUMENTS = 'type/missing-type-arguments'; export const CODE_TYPE_MISSING_TYPE_HINT = 'type/missing-type-hint'; @@ -27,6 +33,30 @@ export const CODE_TYPE_MISSING_TYPE_HINT = 'type/missing-type-hint'; // Type checking // ----------------------------------------------------------------------------- +export const argumentTypeMustMatchParameterType = (services: SafeDsServices) => { + const nodeMapper = services.helpers.NodeMapper; + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsArgument, accept: ValidationAcceptor) => { + const parameter = nodeMapper.argumentToParameter(node); + if (!parameter) { + return; + } + + const argumentType = typeComputer.computeType(node); + const parameterType = typeComputer.computeType(parameter); + + if (!typeChecker.isAssignableTo(argumentType, parameterType)) { + accept('error', `Expected type '${parameterType}' but got '${argumentType}'.`, { + node, + property: 'value', + code: CODE_TYPE_MISMATCH, + }); + } + }; +}; + export const callReceiverMustBeCallable = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; @@ -60,6 +90,187 @@ export const callReceiverMustBeCallable = (services: SafeDsServices) => { }; }; +export const indexedAccessReceiverMustBeListOrMap = (services: SafeDsServices) => { + const coreTypes = services.types.CoreTypes; + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { + const receiverType = typeComputer.computeType(node.receiver); + if ( + !typeChecker.isAssignableTo(receiverType, coreTypes.List) && + !typeChecker.isAssignableTo(receiverType, coreTypes.Map) + ) { + accept('error', `Expected type '${coreTypes.List}' or '${coreTypes.Map}' but got '${receiverType}'.`, { + node: node.receiver, + code: CODE_TYPE_MISMATCH, + }); + } + }; +}; + +export const indexedAccessIndexMustHaveCorrectType = (services: SafeDsServices) => { + const coreTypes = services.types.CoreTypes; + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { + const receiverType = typeComputer.computeType(node.receiver); + if (typeChecker.isAssignableTo(receiverType, coreTypes.List)) { + const indexType = typeComputer.computeType(node.index); + if (!typeChecker.isAssignableTo(indexType, coreTypes.Int)) { + accept('error', `Expected type '${coreTypes.Int}' but got '${indexType}'.`, { + node, + property: 'index', + code: CODE_TYPE_MISMATCH, + }); + } + } + }; +}; + +export const infixOperationOperandsMustHaveCorrectType = (services: SafeDsServices) => { + const coreTypes = services.types.CoreTypes; + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsInfixOperation, accept: ValidationAcceptor): void => { + const leftType = typeComputer.computeType(node.leftOperand); + const rightType = typeComputer.computeType(node.rightOperand); + switch (node.operator) { + case 'or': + case 'and': + if (!typeChecker.isAssignableTo(leftType, coreTypes.Boolean)) { + accept('error', `Expected type '${coreTypes.Boolean}' but got '${leftType}'.`, { + node: node.leftOperand, + code: CODE_TYPE_MISMATCH, + }); + } + if (!typeChecker.isAssignableTo(rightType, coreTypes.Boolean)) { + accept('error', `Expected type '${coreTypes.Boolean}' but got '${rightType}'.`, { + node: node.rightOperand, + code: CODE_TYPE_MISMATCH, + }); + } + return; + case '<': + case '<=': + case '>=': + case '>': + case '+': + case '-': + case '*': + case '/': + if ( + !typeChecker.isAssignableTo(leftType, coreTypes.Float) && + !typeChecker.isAssignableTo(leftType, coreTypes.Int) + ) { + accept('error', `Expected type '${coreTypes.Float}' or '${coreTypes.Int}' but got '${leftType}'.`, { + node: node.leftOperand, + code: CODE_TYPE_MISMATCH, + }); + } + if ( + !typeChecker.isAssignableTo(rightType, coreTypes.Float) && + !typeChecker.isAssignableTo(rightType, coreTypes.Int) + ) { + accept( + 'error', + `Expected type '${coreTypes.Float}' or '${coreTypes.Int}' but got '${rightType}'.`, + { + node: node.rightOperand, + code: CODE_TYPE_MISMATCH, + }, + ); + } + return; + } + }; +}; + +export const parameterDefaultValueTypeMustMatchParameterType = (services: SafeDsServices) => { + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsParameter, accept: ValidationAcceptor) => { + const defaultValue = node.defaultValue; + if (!defaultValue) { + return; + } + + const defaultValueType = typeComputer.computeType(defaultValue); + const parameterType = typeComputer.computeType(node); + + if (!typeChecker.isAssignableTo(defaultValueType, parameterType)) { + accept('error', `Expected type '${parameterType}' but got '${defaultValueType}'.`, { + node, + property: 'defaultValue', + code: CODE_TYPE_MISMATCH, + }); + } + }; +}; + +export const prefixOperationOperandMustHaveCorrectType = (services: SafeDsServices) => { + const coreTypes = services.types.CoreTypes; + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsPrefixOperation, accept: ValidationAcceptor): void => { + const operandType = typeComputer.computeType(node.operand); + switch (node.operator) { + case 'not': + if (!typeChecker.isAssignableTo(operandType, coreTypes.Boolean)) { + accept('error', `Expected type '${coreTypes.Boolean}' but got '${operandType}'.`, { + node, + property: 'operand', + code: CODE_TYPE_MISMATCH, + }); + } + return; + case '-': + if ( + !typeChecker.isAssignableTo(operandType, coreTypes.Float) && + !typeChecker.isAssignableTo(operandType, coreTypes.Int) + ) { + accept( + 'error', + `Expected type '${coreTypes.Float}' or '${coreTypes.Int}' but got '${operandType}'.`, + { + node, + property: 'operand', + code: CODE_TYPE_MISMATCH, + }, + ); + } + return; + } + }; +}; + +export const yieldTypeMustMatchResultType = (services: SafeDsServices) => { + const typeChecker = services.types.TypeChecker; + const typeComputer = services.types.TypeComputer; + + return (node: SdsYield, accept: ValidationAcceptor) => { + const result = node.result?.ref; + if (!result) { + return; + } + + const yieldType = typeComputer.computeType(node); + const resultType = typeComputer.computeType(result); + + if (!typeChecker.isAssignableTo(yieldType, resultType)) { + accept('error', `Expected type '${resultType}' but got '${yieldType}'.`, { + node, + property: 'result', + code: CODE_TYPE_MISMATCH, + }); + } + }; +}; + // ----------------------------------------------------------------------------- // Missing type arguments // ----------------------------------------------------------------------------- diff --git a/packages/safe-ds-lang/tests/language/typing/safe-ds-type-checker.test.ts b/packages/safe-ds-lang/tests/language/typing/safe-ds-type-checker.test.ts index bf7e44c59..d1e8e5b6b 100644 --- a/packages/safe-ds-lang/tests/language/typing/safe-ds-type-checker.test.ts +++ b/packages/safe-ds-lang/tests/language/typing/safe-ds-type-checker.test.ts @@ -144,7 +144,7 @@ describe('SafeDsTypeChecker', async () => { { type1: callableType8, type2: callableType7, - expected: false, + expected: true, }, { type1: callableType9, diff --git a/packages/safe-ds-lang/tests/language/validation/creator.ts b/packages/safe-ds-lang/tests/language/validation/creator.ts index 2122ca890..6640d9d54 100644 --- a/packages/safe-ds-lang/tests/language/validation/creator.ts +++ b/packages/safe-ds-lang/tests/language/validation/creator.ts @@ -6,7 +6,7 @@ import fs from 'fs'; import { findTestChecks } from '../../helpers/testChecks.js'; import { getSyntaxErrors, SyntaxErrorsInCodeError } from '../../helpers/diagnostics.js'; import { EmptyFileSystem, URI } from 'langium'; -import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { createSafeDsServices } from '../../../src/language/index.js'; import { Range } from 'vscode-languageserver'; import { TestDescription, TestDescriptionError } from '../../helpers/testDescription.js'; @@ -40,7 +40,7 @@ const createValidationTest = async (parentDirectory: URI, uris: URI[]): Promise< } for (const check of checksResult.value) { - const regex = /\s*(?no\s+)?(?\S+)\s*(?:(?r)?"(?[^"]*)")?/gu; + const regex = /\s*(?no\s+)?(?\S+)\s*(?:(?r)?"(?.*)")?/gu; const match = regex.exec(check.comment); // Overall comment is invalid diff --git a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/input.sdstest index c6b48eed9..3fa0240f6 100644 --- a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/input.sdstest +++ b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/input.sdstest @@ -4,6 +4,6 @@ fun f1(param: (a: Int, b: Int, c: Int) -> r: Int) fun f2(param: (a: Int, b: Int, c: Int) -> ()) segment test(param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_3") param3: Int = 0) { - f1((param1: Int, param2: Int, param3: Int = 0) -> 1); - f2((param1: Int, param2: Int, param3: Int = 0) {}); + f1((a: Int, b: Int, c: Int = 0) -> 1); + f2((a: Int, b: Int, c: Int = 0) {}); } diff --git a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py index ae228dbf2..f48810d87 100644 --- a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py +++ b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py @@ -1,7 +1,7 @@ # Segments --------------------------------------------------------------------- def test(param1, param_2, param_3=0): - f1(lambda param1, param2, param3=0: 1) - def __gen_block_lambda_0(param1, param2, param3=0): + f1(lambda a, b, c=0: 1) + def __gen_block_lambda_0(a, b, c=0): pass f2(__gen_block_lambda_0) diff --git a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py.map index 4b451a86c..bbe73b1bf 100644 --- a/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py.map +++ b/packages/safe-ds-lang/tests/resources/generation/declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","param1","param2","param3","f1","f2"],"mappings":"AAAA;;AAKA,IAAQA,IAAI,CAACC,MAAM,EAA8BC,OAAM,EAA8BC,OAAM,CAAQ,CAAC;IAChGC,EAAE,CAAC,OAACH,MAAM,EAAOC,MAAM,EAAOC,MAAM,CAAQ,CAAC,EAAK,CAAC;IAChD,yBAACF,MAAM,EAAOC,MAAM,EAAOC,MAAM,CAAQ,CAAC;QAAE,IAAE;IAAjDE,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.sdstest"],"names":["test","param1","param2","param3","f1","a","b","c","f2"],"mappings":"AAAA;;AAKA,IAAQA,IAAI,CAACC,MAAM,EAA8BC,OAAM,EAA8BC,OAAM,CAAQ,CAAC;IAChGC,EAAE,CAAC,OAACC,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC,EAAK,CAAC;IACjC,yBAACF,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAAE,IAAE;IAAlCC,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/input.sdstest index bdfcd497c..408b1159b 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/input.sdstest +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/input.sdstest @@ -9,7 +9,7 @@ pipeline test { f1((a: Int, b: Int = 2) { yield d = g(); }); - f1((a: Int, c: Int) { + f1((a: Int, b: Int) { yield d = g(); }); f2(() {}); diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py index 1f02920f7..4ab7b98a8 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py @@ -5,7 +5,7 @@ def __gen_block_lambda_0(a, b=2): __gen_block_lambda_result_d = g() return __gen_block_lambda_result_d f1(__gen_block_lambda_0) - def __gen_block_lambda_1(a, c): + def __gen_block_lambda_1(a, b): __gen_block_lambda_result_d = g() return __gen_block_lambda_result_d f1(__gen_block_lambda_1) diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py.map index 353842a02..242999d3f 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py.map +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/block lambda/output/tests/generator/blockLambda/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","a","b","d","g","f1","c","f2"],"mappings":"AAAA;;AAOA,IAASA,IAAI;IACN,yBAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAClB,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA,yBAACJ,CAAC,EAAOK,CAAC;QACT,0BAAMH,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA;QAAG,IAAE;IAARE,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.sdstest"],"names":["test","a","b","d","g","f1","f2"],"mappings":"AAAA;;AAOA,IAASA,IAAI;IACN,yBAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAClB,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA,yBAACJ,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA;QAAG,IAAE;IAARC,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/input.sdstest index 6f39b97ec..153bdb4a5 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/input.sdstest +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/input.sdstest @@ -4,5 +4,5 @@ fun f(param: (a: Int, b: Int) -> r: Int) pipeline test { f((a, b = 2) -> 1); - f((a, c) -> 1); + f((a, b) -> 1); } diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py index 7f130276a..ad30c61c5 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py @@ -2,4 +2,4 @@ def test(): f(lambda a, b=2: 1) - f(lambda a, c: 1) + f(lambda a, b: 1) diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py.map b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py.map index db976a153..38b178bd0 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py.map +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","a","b","c"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,CAAG,CAAC,EAAK,CAAC;IACjBF,CAAC,CAAC,OAACC,CAAC,EAAEE,CAAC,EAAK,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.sdstest"],"names":["test","f","a","b"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,CAAG,CAAC,EAAK,CAAC;IACjBF,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,EAAK,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/safe-ds-lang/tests/resources/generation/expressions/member access/input.sdstest b/packages/safe-ds-lang/tests/resources/generation/expressions/member access/input.sdstest index 71a924027..5e52b3b23 100644 --- a/packages/safe-ds-lang/tests/resources/generation/expressions/member access/input.sdstest +++ b/packages/safe-ds-lang/tests/resources/generation/expressions/member access/input.sdstest @@ -10,7 +10,7 @@ class C() { attr a: Int @PythonName("c") attr b: Int - @PythonCall("$param.i($this)") fun i(param: Any?) + @PythonCall("$param.i($this)") fun i(param: Any?) -> result: Boolean } fun factory() -> instance: C? diff --git a/packages/safe-ds-lang/tests/resources/validation/other/imports/main with issues.sdstest b/packages/safe-ds-lang/tests/resources/validation/other/imports/main with issues.sdstest index bb2154698..85cdcf696 100644 --- a/packages/safe-ds-lang/tests/resources/validation/other/imports/main with issues.sdstest +++ b/packages/safe-ds-lang/tests/resources/validation/other/imports/main with issues.sdstest @@ -2,9 +2,9 @@ package tests.other.imports // $TEST$ error "The package 'tests.other.imports.missing' does not exist." from »tests.other.imports.missing« import * -// $TEST$ error ""The package 'tests.other.imports.missing' does not exist." +// $TEST$ error "The package 'tests.other.imports.missing' does not exist." from »tests.other.imports.missing« import C -// $TEST$ error ""The package 'tests.other.imports.missing' does not exist." +// $TEST$ error "The package 'tests.other.imports.missing' does not exist." from »tests.other.imports.missing« import C as D // $TEST$ warning "The package 'tests.other.imports.empty' is empty." diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/arguments.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/arguments.sdstest deleted file mode 100644 index 75895a631..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/arguments.sdstest +++ /dev/null @@ -1,336 +0,0 @@ -package tests.validation.typeChecking.arguments - -step myStep(vararg variadicParam: Int) { - - // $TEST$ no error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»B()«); - // $TEST$ error "An argument of type 'C' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(callableType = »C()«); - // $TEST$ error "An argument of type 'D' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»someVariantOfMyEnum2()«); - // $TEST$ error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type '(Int) -> (Int)'." - f1(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f1(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'C'." - f2(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'C'." - f2(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type 'C'." - f2(»B()«); - // $TEST$ no error "An argument of type 'C' cannot be assigned to a parameter of type 'C'." - f2(classType = »C()«); - // $TEST$ no error "An argument of type 'D' cannot be assigned to a parameter of type 'C'." - f2(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'C'." - f2(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'C'." - f2(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'C'." - f2(»someVariantOfMyEnum2()«); - // $TEST$ error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'C'." - f2(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'C'." - f2(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'C'." - f2(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'C'." - f2(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'C'." - f2(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type 'C'." - f2(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'C'." - f2(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f2(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»B()«); - // $TEST$ error "An argument of type 'C' cannot be assigned to a parameter of type 'MyEnum1'." - f3(enumType = »C()«); - // $TEST$ error "An argument of type 'D' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»maybeC()«); - // $TEST$ no error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»someVariantOfMyEnum2()«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»MyEnum1.Variant1«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'MyEnum1'." - f3(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f3(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»B()«); - // $TEST$ error "An argument of type 'C' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(enumVariantType = »C()«); - // $TEST$ error "An argument of type 'D' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»someVariantOfMyEnum2()«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'MyEnum1.Variant1'." - f4(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f4(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'union'." - f5(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'union'." - f5(»f2«); - // $TEST$ no error "An argument of type 'B' cannot be assigned to a parameter of type 'union'." - f5(»B()«); - // $TEST$ no error "An argument of type 'C' cannot be assigned to a parameter of type 'union'." - f5(unionType = »C()«); - // $TEST$ no error "An argument of type 'D' cannot be assigned to a parameter of type 'union'." - f5(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'union'." - f5(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'union'." - f5(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'union'." - f5(»someVariantOfMyEnum2()«); - // $TEST$ error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'union'." - f5(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'union'." - f5(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'union'." - f5(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'union'." - f5(»aOrC()«); - // $TEST$ no error "An argument of type 'union' cannot be assigned to a parameter of type 'union'." - f5(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type 'union'." - f5(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'union'." - f5(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f5(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type '$Unresolved'." - f6(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type '$Unresolved'." - f6(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type '$Unresolved'." - f6(»B()«); - // $TEST$ error "An argument of type 'C' cannot be assigned to a parameter of type '$Unresolved'." - f6(unresolvedType = »C()«); - // $TEST$ error "An argument of type 'D' cannot be assigned to a parameter of type '$Unresolved'." - f6(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type '$Unresolved'." - f6(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type '$Unresolved'." - f6(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type '$Unresolved'." - f6(»someVariantOfMyEnum2()«); - // $TEST$ error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type '$Unresolved'." - f6(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type '$Unresolved'." - f6(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type '$Unresolved'." - f6(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type '$Unresolved'." - f6(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type '$Unresolved'." - f6(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type '$Unresolved'." - f6(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type '$Unresolved'." - f6(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f6(unresolved = »1«); - - // $TEST$ error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'vararg'." - f7(»intToInt«); - // $TEST$ error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'vararg'." - f7(»f2«); - // $TEST$ error "An argument of type 'B' cannot be assigned to a parameter of type 'vararg'." - f7(»B()«); - // $TEST$ no error "An argument of type 'C' cannot be assigned to a parameter of type 'vararg'." - f7(unresolvedType = »C()«); - // $TEST$ no error "An argument of type 'D' cannot be assigned to a parameter of type 'vararg'." - f7(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'vararg'." - f7(»maybeC()«); - // $TEST$ error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'vararg'." - f7(»someVariantOfMyEnum1()«); - // $TEST$ error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'vararg'." - f7(»someVariantOfMyEnum2()«); - // $TEST$ error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'vararg'." - f7(»MyEnum1.Variant1«); - // $TEST$ error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'vararg'." - f7(»MyEnum1.Variant2«); - // $TEST$ error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'vararg'." - f7(»MyEnum2.Variant1«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'vararg'." - f7(»aOrC()«); - // $TEST$ error "An argument of type 'union' cannot be assigned to a parameter of type 'vararg'." - f7(»bOrC()«); - // $TEST$ error "An argument of type 'vararg' cannot be assigned to a parameter of type 'vararg'." - f7(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'vararg'." - f7(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f7(unresolved = »1«); - - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f8(»(vararg a: Int) {}«); - - // $TEST$ no error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'Any'." - f9(»intToInt«); - // $TEST$ no error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'Any'." - f9(»f2«); - // $TEST$ no error "An argument of type 'B' cannot be assigned to a parameter of type 'Any'." - f9(»B()«); - // $TEST$ no error "An argument of type 'C' cannot be assigned to a parameter of type 'Any'." - f9(callableType = »C()«); - // $TEST$ no error "An argument of type 'D' cannot be assigned to a parameter of type 'Any'." - f9(»D()«); - // $TEST$ error "An argument of type 'C?' cannot be assigned to a parameter of type 'Any'." - f9(»maybeC()«); - // $TEST$ no error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'Any'." - f9(»someVariantOfMyEnum1()«); - // $TEST$ no error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'Any'." - f9(»someVariantOfMyEnum2()«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'Any'." - f9(»MyEnum1.Variant1«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'Any'." - f9(»MyEnum1.Variant2«); - // $TEST$ no error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'Any'." - f9(»MyEnum2.Variant1«); - // $TEST$ no error "An argument of type 'union' cannot be assigned to a parameter of type 'Any'." - f9(»aOrC()«); - // $TEST$ no error "An argument of type 'union' cannot be assigned to a parameter of type 'Any'." - f9(»bOrC()«); - // $TEST$ no error "An argument of type 'vararg' cannot be assigned to a parameter of type 'Any'." - f9(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'Any'." - f9(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f9(unresolved = »1«); - - // $TEST$ no error "An argument of type '(Int) -> (Int)' cannot be assigned to a parameter of type 'Any?'." - f10(»intToInt«); - // $TEST$ no error "An argument of type '(C) -> ()' cannot be assigned to a parameter of type 'Any?'." - f10(»f2«); - // $TEST$ no error "An argument of type 'B' cannot be assigned to a parameter of type 'Any?'." - f10(»B()«); - // $TEST$ no error "An argument of type 'C' cannot be assigned to a parameter of type 'Any?'." - f10(callableType = »C()«); - // $TEST$ no error "An argument of type 'D' cannot be assigned to a parameter of type 'Any?'." - f10(»D()«); - // $TEST$ no error "An argument of type 'C?' cannot be assigned to a parameter of type 'Any?'." - f10(»maybeC()«); - // $TEST$ no error "An argument of type 'MyEnum1' cannot be assigned to a parameter of type 'Any?'." - f10(»someVariantOfMyEnum1()«); - // $TEST$ no error "An argument of type 'MyEnum2' cannot be assigned to a parameter of type 'Any?'." - f10(»someVariantOfMyEnum2()«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant1' cannot be assigned to a parameter of type 'Any?'." - f10(»MyEnum1.Variant1«); - // $TEST$ no error "An argument of type 'MyEnum1.Variant2' cannot be assigned to a parameter of type 'Any?'." - f10(»MyEnum1.Variant2«); - // $TEST$ no error "An argument of type 'MyEnum2.Variant1' cannot be assigned to a parameter of type 'Any?'." - f10(»MyEnum2.Variant1«); - // $TEST$ no error "An argument of type 'union' cannot be assigned to a parameter of type 'Any?'." - f10(»aOrC()«); - // $TEST$ no error "An argument of type 'union' cannot be assigned to a parameter of type 'Any?'." - f10(»bOrC()«); - // $TEST$ no error "An argument of type 'vararg' cannot be assigned to a parameter of type 'Any?'." - f10(»variadicParam«); - // $TEST$ no error "An argument of type '$Unresolved' cannot be assigned to a parameter of type 'Any?'." - f10(»unresolved«); - // $TEST$ no error r"An argument of type '[^']*' cannot be assigned to a parameter of type '[^']*'." - f10(unresolved = »1«); -} - -fun f1(callableType: (a: Int) -> (r: Int)) -fun f2(classType: C) -fun f3(enumType: MyEnum1) -fun f4(enumVariantType: MyEnum1.Variant1) -fun f5(unionType: union) -fun f6(unresolvedType: Unresolved) -fun f7(vararg variadicType: C) -fun f8(callableType: (vararg a: Int) -> ()) -fun f9(any: Any) -fun f10(anyOrNull: Any?) - -class A() -class B() -class C() -class D() sub C - -enum MyEnum1 { - Variant1 - Variant2 -} -enum MyEnum2 { - Variant1 - Variant2 -} - -fun maybeC() -> instanceOrNull: C? -fun aOrC() -> instance: union -fun bOrC() -> instance: union -fun someVariantOfMyEnum1() -> variant: MyEnum1 -fun someVariantOfMyEnum2() -> variant: MyEnum2 -fun intToInt(a: Int) -> (r: Int) diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/defaultValues.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/defaultValues.sdstest deleted file mode 100644 index f1ce05cde..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/defaultValues.sdstest +++ /dev/null @@ -1,19 +0,0 @@ -package tests.validation.typeChecking.defaultValues - -fun myFun( - // $TEST$ no error "An default value of type 'Int' cannot be assigned to a parameter of type 'Int'." - param1: Int = »1«, - - // $TEST$ error "A default value of type 'String' cannot be assigned to a parameter of type 'Int'." - param2: Int = »""«, -) - -fun myOtherFun(callback: (a: Int) -> ()) - -step myStep() { - // $TEST$ no error "An default value of type 'Int' cannot be assigned to a parameter of type 'Int'." - myOtherFun((a = »1«) {}); - - // $TEST$ error "A default value of type 'String' cannot be assigned to a parameter of type 'Int'." - myOtherFun((a = »""«) {}); -} diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/indexedAccesses.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/indexedAccesses.sdstest deleted file mode 100644 index c741d5379..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/indexedAccesses.sdstest +++ /dev/null @@ -1,39 +0,0 @@ -package tests.validation.typeChecking.indexedAccesses - -step f(a: Int, vararg b: Int) { - // $TEST$ error "The receiver of an indexed access must refer to a variadic parameter." - »a«[0]; - - // $TEST$ no error "The receiver of an indexed access must refer to a variadic parameter." - »b«[0]; - - // $TEST$ no error "The receiver of an indexed access must refer to a variadic parameter." - »unresolved«[0]; - - // $TEST$ no error "The receiver of an indexed access must refer to a variadic parameter." - »C.unresolved«[0]; - - // $TEST$ no error "The index of an indexed access must be an instance of the class 'Int'." - b[»0«]; - - // $TEST$ error "The index of an indexed access must be an instance of the class 'Int'." - b[»""«]; - - // $TEST$ error "The index of an indexed access must be an instance of the class 'Int'." - b[»g«]; - - // $TEST$ error "The index of an indexed access must be an instance of the class 'Int'." - b[»h()«]; - - // $TEST$ error "The index of an indexed access must be an instance of the class 'Int'." - b[»b«]; - - // $TEST$ no error "The index of an indexed access must be an instance of the class 'Int'." - b[»unresolved«]; - - // $TEST$ no error "The index of an indexed access must be an instance of the class 'Int'." - b[»C.unresolved«]; -} - -fun g() -fun h() -> index: Int? diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/infixOperations.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/infixOperations.sdstest deleted file mode 100644 index 418927427..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/infixOperations.sdstest +++ /dev/null @@ -1,230 +0,0 @@ -package tests.validation.typeChecking.infixOperations - -step f(vararg a: Int) { - - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »true« or »true« ; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »false« or »false«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »i()« or »i()«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »0« or »0«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »a« or »a«; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »unresolved« or »unresolved«; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »C.unresolved« or »C.unresolved«; - - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »true« and »true«; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »false« and »false«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »i()« and »i()«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »0« and »0«; - // $TEST$ error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »a« and »a«; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »unresolved« and »unresolved«; - // $TEST$ no error "The left operand of a logical infix operation must be an instance of the class 'Boolean'." - // $TEST$ no error "The right operand of a logical infix operation must be an instance of the class 'Boolean'." - »C.unresolved« and »C.unresolved«; - - - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0.0« + »0.0«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0« + »0«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »h()« + »h()«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »""« + »""«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »a« + »a«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »unresolved« + »unresolved«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« + »C.unresolved«; - - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0.0« - »0.0«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0« - »0«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »h()« - »h()«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »""« - »""«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »a« - »a«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »unresolved« - »unresolved«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« - »C.unresolved«; - - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0.0« * »0.0«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0« * »0«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »h()« * »h()«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »""« * »""«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »a« * »a«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »unresolved« * »unresolved«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« * »C.unresolved«; - - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0.0« / »0.0«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »0« / »0«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »h()« / »h()«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »""« / »""«; - // $TEST$ error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »a« / »a«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »unresolved« / »unresolved«; - // $TEST$ no error "The left operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of an arithmetic infix operation must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« / »C.unresolved«; - - - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0.0« < »0.0«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0« < »0«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »h()« < »h()«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »""« < »""«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »a« < »a«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »unresolved« < »unresolved«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« < »C.unresolved«; - - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0.0« <= »0.0«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0« <= »0«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »h()« <= »h()«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »""« <= »""«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »a« <= »a«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »unresolved« <= »unresolved«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« <= »C.unresolved«; - - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0.0« >= »0.0«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0« >= »0«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »h()« >= »h()«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »""« >= »""«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »a« >= »a«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »unresolved« >= »unresolved«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« >= »C.unresolved«; - - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0.0« > »0.0«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »0« > »0«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »h()« > »h()«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »""« > »""«; - // $TEST$ error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »a« > »a«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »unresolved« > »unresolved«; - // $TEST$ no error "The left operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - // $TEST$ no error "The right operand of a comparison must be an instance of the class 'Float' or the class 'Int'." - »C.unresolved« > »C.unresolved«; -} - -fun g() -fun h() -> index: Int? -fun i() -> isTrue: Boolean? diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/prefixOperations.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/prefixOperations.sdstest deleted file mode 100644 index d2c43af31..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/prefixOperations.sdstest +++ /dev/null @@ -1,38 +0,0 @@ -package tests.validation.typeChecking.prefixOperations - -step f(vararg a: Int) { - - // $TEST$ no error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »true«; - // $TEST$ no error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »false«; - // $TEST$ error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »i()«; - // $TEST$ error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »0«; - // $TEST$ error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »a«; - // $TEST$ no error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »unresolved«; - // $TEST$ no error "The operand of a logical negation must be an instance of the class 'Boolean'." - not »C.unresolved«; - - // $TEST$ no error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»0.0«; - // $TEST$ no error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»0«; - // $TEST$ error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»h()«; - // $TEST$ error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»""«; - // $TEST$ error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»a«; - // $TEST$ no error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»unresolved«; - // $TEST$ no error "The operand of an arithmetic negation must be an instance of the class 'Float' or the class 'Int'." - -»C.unresolved«; -} - -fun g() -fun h() -> index: Int? -fun i() -> isTrue: Boolean? diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/schemaEffectArguments.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/schemaEffectArguments.sdstest deleted file mode 100644 index c325a2ef5..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/schemaEffectArguments.sdstest +++ /dev/null @@ -1,22 +0,0 @@ -package tests.validation.typeChecking.schemaEffectArguments - -predicate schemaEffects (){ - - /* $ReadSchema ---------------------------------------------------------------------------------------------------*/ - // $TEST$ error "An argument of type 'Boolean' cannot be assigned to a parameter of type 'String'." - $readSchema(»false«), - - // $TEST$ no error "An argument of type 'String' cannot be assigned to a parameter of type 'String'." - $readSchema(»"datasetNameStr"«), - - /* $CheckColumn --------------------------------------------------------------------------------------------------*/ - // $TEST$ error "An argument of type 'Boolean' cannot be assigned to a parameter of type '::$SchemaType'." - // $TEST$ error "An argument of type 'Int' cannot be assigned to a parameter of type 'vararg'." - // $TEST$ no error "An argument of type 'safeds.lang.String' cannot be assigned to a parameter of type 'safeds.lang.String'." - $checkColumn(»false«, »0«, »"columnNameStr2"«), - - // $TEST$ no error "An argument of type '::$SchemaType' cannot be assigned to a parameter of type '::$SchemaType'." - // $TEST$ no error "An argument of type 'String' cannot be assigned to a parameter of type 'vararg'." - // $TEST$ no error "An argument of type 'String' cannot be assigned to a parameter of type 'String'." - $checkColumn(»::ASchema«, »"columnNameStr1"«, »"columnNameStr2"«) -} diff --git a/packages/safe-ds-lang/tests/resources/validation/skip-old/yields.sdstest b/packages/safe-ds-lang/tests/resources/validation/skip-old/yields.sdstest deleted file mode 100644 index 3cfeb4c78..000000000 --- a/packages/safe-ds-lang/tests/resources/validation/skip-old/yields.sdstest +++ /dev/null @@ -1,13 +0,0 @@ -package tests.validation.typeChecking.yields - -step myStep1() -> result: Int { - - // $TEST$ no error "A value of type 'Int' cannot be assigned to a result of type 'Int'." - yield result = »1«; -} - -step myStep2() -> result: Int { - - // $TEST$ error "A value of type 'String' cannot be assigned to a result of type 'Int'." - yield result = »""«; -} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/arguments/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/arguments/main.sdstest new file mode 100644 index 000000000..95aa5c2f3 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/arguments/main.sdstest @@ -0,0 +1,20 @@ +package tests.validation.types.checking.arguments + +fun f(p: Int) + +segment mySegment() { + // $TEST$ no error r"Expected type .* but got .*\." + f(»1«); + + // $TEST$ no error r"Expected type .* but got .*\." + f(p = »1«); + + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + f(»""«); + + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + f(p = »""«); + + // $TEST$ no error r"Expected type .* but got .*\." + f(unresolved = »1«); +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/default values/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/default values/main.sdstest new file mode 100644 index 000000000..8dd59f9b0 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/default values/main.sdstest @@ -0,0 +1,19 @@ +package tests.validation.types.checking.defaultValues + +fun myFun( + // $TEST$ no error r"Expected type .* but got .*\." + param1: Int = »1«, + + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + param2: Int = »""«, +) + +fun myOtherFun(callback: (a: Int) -> ()) + +segment mySegment() { + // $TEST$ no error r"Expected type .* but got .*\." + myOtherFun((a = »1«) {}); + + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + myOtherFun((a = »""«) {}); +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access on list/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access on list/main.sdstest new file mode 100644 index 000000000..bd29412a0 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access on list/main.sdstest @@ -0,0 +1,15 @@ +package tests.validation.types.checking.indexedAccessOnList + +pipeline myPipeline { + // $TEST$ no error r"Expected type 'Int' but got .*\." + [1][»0«]; + + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + [0][»""«]; + + // $TEST$ no error r"Expected type 'Int' but got .*\." + {"": ""}[»""«]; + + // $TEST$ no error r"Expected type 'Int' but got .*\." + unresolved[»""«]; +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access receiver/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access receiver/main.sdstest new file mode 100644 index 000000000..eddbf11ea --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/indexed access receiver/main.sdstest @@ -0,0 +1,15 @@ +package tests.validation.types.checking.indexedAccessReceiver + +pipeline myPipeline { + // $TEST$ no error r"Expected type 'List' or 'Map' but got .*\." + »[1]«[0]; + + // $TEST$ no error r"Expected type 'List' or 'Map' but got .*\." + »{0: 1}«[0]; + + // $TEST$ error "Expected type 'List' or 'Map' but got 'literal<1>'." + »1«[0]; + + // $TEST$ error "Expected type 'List' or 'Map' but got '?'." + »unresolved«[0]; +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/infix operations/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/infix operations/main.sdstest new file mode 100644 index 000000000..a4686c1b3 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/infix operations/main.sdstest @@ -0,0 +1,130 @@ +package tests.validation.types.checking.infixOperations + +pipeline myPipeline { + + // $TEST$ no error r"Expected type 'Boolean' but got .*\." + // $TEST$ no error r"Expected type 'Boolean' but got .*\." + »true« or »true« ; + // $TEST$ error "Expected type 'Boolean' but got 'literal<0>'." + // $TEST$ error "Expected type 'Boolean' but got 'literal<0>'." + »0« or »0«; + // $TEST$ error "Expected type 'Boolean' but got '?'." + // $TEST$ error "Expected type 'Boolean' but got '?'." + »unresolved« or »unresolved«; + + // $TEST$ no error r"Expected type 'Boolean' but got .*\." + // $TEST$ no error r"Expected type 'Boolean' but got .*\." + »true« and »true«; + // $TEST$ error "Expected type 'Boolean' but got 'literal<0>'." + // $TEST$ error "Expected type 'Boolean' but got 'literal<0>'." + »0« and »0«; + // $TEST$ error "Expected type 'Boolean' but got '?'." + // $TEST$ error "Expected type 'Boolean' but got '?'." + »unresolved« and »unresolved«; + + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« + »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« + »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« + »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« + »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« - »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« - »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« - »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« - »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« * »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« * »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« * »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« * »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« / »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« / »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« / »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« / »unresolved«; + + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« < »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« < »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« < »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« < »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« <= »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« <= »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« <= »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« <= »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« >= »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« >= »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« >= »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« >= »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0.0« > »0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + »0« > »0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + »""« > »""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + »unresolved« > »unresolved«; +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/prefix operations/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/prefix operations/main.sdstest new file mode 100644 index 000000000..275f0f79b --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/prefix operations/main.sdstest @@ -0,0 +1,20 @@ +package tests.validation.types.checking.prefixOperations + +segment mySegment() { + + // $TEST$ no error r"Expected type 'Boolean' but got .*\." + not »true«; + // $TEST$ error "Expected type 'Boolean' but got 'literal<0>'." + not »0«; + // $TEST$ error "Expected type 'Boolean' but got '?'." + not »unresolved«; + + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + -»0.0«; + // $TEST$ no error r"Expected type 'Float' or 'Int' but got .*\." + -»0«; + // $TEST$ error "Expected type 'Float' or 'Int' but got 'literal<"">'." + -»""«; + // $TEST$ error "Expected type 'Float' or 'Int' but got '?'." + -»unresolved«; +} diff --git a/packages/safe-ds-lang/tests/resources/validation/types/checking/yields/main.sdstest b/packages/safe-ds-lang/tests/resources/validation/types/checking/yields/main.sdstest new file mode 100644 index 000000000..79a363dfd --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/validation/types/checking/yields/main.sdstest @@ -0,0 +1,16 @@ +package tests.validation.types.checking.yields + +segment mySegment1() -> result: Int { + // $TEST$ no error r"Expected type .* but got .*\." + yield »result« = 1; +} + +segment mySegment2() -> result: Int { + // $TEST$ error "Expected type 'Int' but got 'literal<"">'." + yield »result« = ""; +} + +segment mySegment3() { + // $TEST$ no error r"Expected type .* but got .*\." + yield »unresolved« = 1; +}