Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compute type of elvis operators with nullable left operand #715

Merged
merged 8 commits into from
Oct 31, 2023
Prev Previous commit
Next Next commit
test: ignore some lines for coverage
  • Loading branch information
lars-reimann committed Oct 31, 2023
commit 097aa81c5c0c0e060126d1055f5ccc2059c639b3
2 changes: 2 additions & 0 deletions packages/safe-ds-lang/src/language/typing/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export class NamedTupleType<T extends SdsDeclaration> extends Type {
/**
* The length of this tuple.
*/
/* c8 ignore start */
get length(): number {
return this.entries.length;
}
/* c8 ignore stop */

/**
* Returns the type of the entry at the given index. If the index is out of bounds, returns `undefined`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { SafeDsClassHierarchy } from './safe-ds-class-hierarchy.js';
import { SafeDsCoreTypes } from './safe-ds-core-types.js';

/* c8 ignore start */
export class SafeDsTypeChecker {
private readonly classHierarchy: SafeDsClassHierarchy;
private readonly coreTypes: SafeDsCoreTypes;
Expand Down Expand Up @@ -196,6 +197,7 @@ export class SafeDsTypeChecker {
return this.isAssignableTo(classType, other);
}

/* c8 ignore start */
private namedTupleTypeIsAssignableTo(type: NamedTupleType<SdsDeclaration>, other: Type): boolean {
return type.equals(other);
}
Expand All @@ -209,3 +211,4 @@ export class SafeDsTypeChecker {
return type.equals(other);
}
}
/* c8 ignore stop */
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
isSdsTemplateString,
isSdsType,
isSdsTypeArgument,
isSdsTypeParameter,
isSdsTypeProjection,
isSdsUnionType,
isSdsYield,
Expand Down Expand Up @@ -192,6 +193,8 @@ export class SafeDsTypeComputer {
return UnknownType;
} else if (isSdsSegment(node)) {
return this.computeTypeOfCallableWithManifestTypes(node);
} else if (isSdsTypeParameter(node)) {
return UnknownType;
} /* c8 ignore start */ else {
throw new Error(`Unexpected node type: ${node.$type}`);
} /* c8 ignore stop */
Expand Down Expand Up @@ -597,7 +600,7 @@ export class SafeDsTypeComputer {
return candidateType;
}
}

/* c8 ignore next */
return this.getAny(isNullable);
}

Expand All @@ -606,10 +609,6 @@ export class SafeDsTypeComputer {
enumVariantTypes: EnumVariantType[],
isNullable: boolean,
): Type {
if (isEmpty(enumTypes) && isEmpty(enumVariantTypes)) {
return this.coreTypes.Nothing;
}

// Build candidates & other
const candidates: Type[] = [];
if (!isEmpty(enumTypes)) {
Expand Down
Loading