6.78. kink/program/COMPILE_ERROR

6.78.1. type compile_error

`compile_error` is an error of compilation of a program.

`compile_error` consists of the following attributes:

• Message: the error message as a `str`.

• From: the `location` of the start of the error.

• To: the `location` of the end of the error.

Invariant

From.program == To.program

From.pos <= To.pos

6.78.1.1. Err.message

`message` returns `Message` attribute of `Err`.

6.78.1.2. Err.from

`from` returns `From` attribute of `Err`.

6.78.1.3. Err.to

`to` returns `To` attribute of `Err`.

6.78.1.4. Err.desc

`desc` returns a `str` which describes the compile error for the programmer.

Example

:PROGRAM.require_from('kink/program/')
:LOCATION.require_from('kink/program/')
:COMPILE_ERROR.require_from('kink/program/')

:Program <- PROGRAM.new('foo.kn' 'Foo + @@ Bar')
:From <- LOCATION.new(Program 6)
:To <- LOCATION.new(Program 8)
:Err <- COMPILE_ERROR.new('unknown operator' From To)
stdout.print_line(Err.desc.repr) # => "unknown operator: [foo.kn L1 C7] Foo + -->@@ Bar"

6.78.1.5. Err1 == Err2

`==` operator, or `op_eq` method, returns whether `Err1` and `Err2` have the equal `Message`, `From`, and `To` attributes.

Precondition

`Err2` must be a `compile_error`.

6.78.2. COMPILE_ERROR.new(Message From To)

`new` returns a new `compile_error` with the passed attributes.

Preconditions

`Message` must be a `str`.

`From` and `To` must be `location` values.

From.program == To.program

From.pos <= To.pos

6.78.3. COMPILE_ERROR.is?(Val)

`is?` returns whether `Val` is a `compile_error`.