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

source-academy / js-slang / 4523966829

pending completion
4523966829

Pull #1378

github

GitHub
Merge 5e0eb1a40 into 8b63af34d
Pull Request #1378: Use UNKNOWN_LOCATION if node location does not exist

3466 of 4530 branches covered (76.51%)

Branch coverage included in aggregate %.

111 of 111 new or added lines in 34 files covered. (100.0%)

10225 of 11863 relevant lines covered (86.19%)

126374.84 hits per line

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

76.32
/src/typeChecker/internalTypeErrors.ts
1
import * as es from 'estree'
2

3
import { UNKNOWN_LOCATION } from '../constants'
61✔
4
import { ErrorSeverity, ErrorType, NodeWithInferredType, SourceError, Type } from '../types'
61✔
5
import { typeToString } from '../utils/stringify'
61✔
6
import * as tsEs from './tsESTree'
7

8
// tslint:disable:max-classes-per-file
9
export class TypeError implements SourceError {
61✔
10
  public type = ErrorType.TYPE
3✔
11
  public severity = ErrorSeverity.WARNING
3✔
12

13
  constructor(public node: NodeWithInferredType<es.Node>, public message: string) {
3✔
14
    node.typability = 'Untypable'
3✔
15
  }
16

17
  get location() {
18
    return this.node.loc ?? UNKNOWN_LOCATION
×
19
  }
20
  public explain() {
21
    return this.message
×
22
  }
23
  public elaborate() {
24
    return this.message
×
25
  }
26
}
27

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

41
export class UnifyError extends InternalTypeError {
61✔
42
  constructor(public LHS: Type, public RHS: Type) {
62✔
43
    super(`Failed to unify LHS: ${typeToString(LHS)}, RHS: ${typeToString(RHS)}`)
62✔
44
  }
45
}
46

47
export class InternalDifferentNumberArgumentsError extends InternalTypeError {
61✔
48
  constructor(public numExpectedArgs: number, public numReceived: number) {
5✔
49
    super(`Expected ${numExpectedArgs} args, got ${numReceived}`)
5✔
50
  }
51
}
52

53
export class InternalCyclicReferenceError extends InternalTypeError {
61✔
54
  constructor(public name: string) {
10✔
55
    super(`contains a cyclic reference to itself`)
10✔
56
  }
57
}
58

59
export class TypecheckError implements SourceError {
61✔
60
  public type = ErrorType.TYPE
1✔
61
  public severity = ErrorSeverity.WARNING
1✔
62

63
  constructor(public node: tsEs.Node | tsEs.TSType, public message: string) {}
1✔
64

65
  get location() {
66
    return this.node.loc ?? UNKNOWN_LOCATION
5!
67
  }
68
  public explain() {
69
    return this.message
1✔
70
  }
71
  public elaborate() {
72
    return this.message
×
73
  }
74
}
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

© 2025 Coveralls, Inc