• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 24611358851

18 Apr 2026 06:42PM UTC coverage: 78.498% (+0.1%) from 78.391%
24611358851

Pull #1893

github

web-flow
Merge 590808047 into 8a89e808f
Pull Request #1893: Error Handling and Stringify Changes

3116 of 4188 branches covered (74.4%)

Branch coverage included in aggregate %.

787 of 960 new or added lines in 76 files covered. (81.98%)

20 existing lines in 11 files now uncovered.

7055 of 8769 relevant lines covered (80.45%)

172276.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.92
/src/typeChecker/internalTypeErrors.ts
1
import { UNKNOWN_LOCATION } from '../constants';
2
import { ErrorSeverity, ErrorType, SourceErrorWithNode, type SourceError } from '../errors/base';
3
import type { Node, NodeWithInferredType, Type } from '../types';
4
import { typeToString } from '../utils/stringify';
5
import type * as tsEs from './tsESTree';
6

7
export class SourceTypeError<T extends Node> extends SourceErrorWithNode<NodeWithInferredType<T>> {
8
  public type = ErrorType.TYPE;
×
9
  public severity = ErrorSeverity.WARNING;
×
10

11
  constructor(
12
    node: NodeWithInferredType<Node>,
NEW
13
    public readonly errMsg: string,
×
14
  ) {
NEW
15
    super(node);
×
UNCOV
16
    node.typability = 'Untypable';
×
17
  }
18

19
  public override explain() {
NEW
20
    return this.errMsg;
×
21
  }
22
  public override elaborate() {
NEW
23
    return this.errMsg;
×
24
  }
25
}
26

27
/**
28
 * Temporary error that will eventually be converted to TypeError as some errors are only thrown
29
 * where there is no handle to the node
30
 */
31
export class InternalTypeError extends Error {
32
  // constructor(public message: string, ...params: any[]) {
33
  //   super(...params)
34
  // }
NEW
35
  constructor(public readonly errMsg: string) {
×
36
    super();
×
37
  }
38
}
39

40
export class UnifyError extends InternalTypeError {
41
  constructor(
NEW
42
    public readonly LHS: Type,
×
NEW
43
    public readonly RHS: Type,
×
44
  ) {
45
    super(`Failed to unify LHS: ${typeToString(LHS)}, RHS: ${typeToString(RHS)}`);
×
46
  }
47
}
48

49
export class InternalDifferentNumberArgumentsError extends InternalTypeError {
50
  constructor(
NEW
51
    public readonly numExpectedArgs: number,
×
NEW
52
    public readonly numReceived: number,
×
53
  ) {
54
    super(`Expected ${numExpectedArgs} args, got ${numReceived}`);
×
55
  }
56
}
57

58
export class InternalCyclicReferenceError extends InternalTypeError {
NEW
59
  constructor(public readonly symbol: string) {
×
60
    super(`contains a cyclic reference to itself`);
×
61
  }
62
}
63

64
export class TypecheckError implements SourceError {
65
  public type = ErrorType.TYPE;
1✔
66
  public severity = ErrorSeverity.WARNING;
1✔
67

68
  constructor(
69
    public node: tsEs.Node | tsEs.TSType,
1✔
70
    public message: string,
1✔
71
  ) {}
72

73
  get location() {
74
    return this.node.loc ?? UNKNOWN_LOCATION;
3!
75
  }
76
  public explain() {
77
    return this.message;
1✔
78
  }
79
  public elaborate() {
80
    return this.message;
×
81
  }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc