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

source-academy / js-slang / 24868044425

24 Apr 2026 01:47AM UTC coverage: 78.522% (+0.1%) from 78.391%
24868044425

push

github

web-flow
Error Handling and Stringify Changes (#1893)

* Modify stringify to prioritize toReplString

* Make the extract declarations helper actually work

* Add ability to change loader for source modules

* Add a new option for controlling how Source modules are loaded

* Improve typing for CSE machine

* Add ability to check if modules are loaded with the wrong Source chapter

* Refactor errors to extend from Error class

* Refactor modules errors

* Refactor parser errors

* Refactor cse machine errors

* Mostly fix error handling in the tracer

* Tidy up generator and explainer implementations for tracer

* Remove unnecessary imports and type guards

* Adjust rttc checks to be type guards instead of returning errors

* Adjust miscellanous error changes

* Add eslint rule for useless constructor

* Fix incorrect ordering for checking exceptionerrors

* Minor changes

* Run format

* Run linting

* Override the message property, but also enable noImplicitOverride to prevent accidental overriding

* Add some documentation to some errors

* Add errors to possible imports for modules

* Update getIds helper

* Minor fix to test case

* Run format

* Allow modules to try and load the context of other modules without crashing

* Fix incorrect stdlib name

* Add some more functions to the stdlib list library

* Change to use GeneralRuntimeError for list

* Revert "Change to use GeneralRuntimeError for list"

This reverts commit 642bd99e6.

* Update src/errors/errors.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Add ability to change manifest and docs importers

* Change how external builtins are defined

* Fix typings and list lib overloads

* Miscellanous changes

* Add the Source equality function to stdlib/misc

* Merge from main branch for tracer

* Add handling for the new importers

* Change errors and made redex a local variable

* Improve tracer typing

* Relocate... (continued)

3125 of 4193 branches covered (74.53%)

Branch coverage included in aggregate %.

899 of 1089 new or added lines in 96 files covered. (82.55%)

21 existing lines in 12 files now uncovered.

7031 of 8741 relevant lines covered (80.44%)

185057.72 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