Error Catalog#

Diagnostics#

Every diagnostic has the form:

[Error type], pos [line/col]: [message]

for example:

Compile error, pos 5/1: resource capacity must be a non-negative integer; got -1

Positions are 1-indexed for both line and column. Runtime errors carry no position, because the failing instruction’s source location is not retained by the VM:

Runtime error: integer division by zero

Phases#

An error belongs to exactly one phase, and the compiler stops at the end of the phase that produced it. A phase reports every independent fault it finds before stopping, so a file with two bad declarations yields two diagnostics rather than one; faults that are consequences of an earlier one in the same construct are suppressed:

SCANNER

Lexical: illegal characters, malformed literals, unterminated strings.

PARSER

Syntactic: a token stream that no production accepts, including reserved words used as identifiers.

SEMANTIC

Everything the grammar cannot express: types, scoping, effect discipline, declaration order, and the constraints in eb-constraints.rst.

RUNTIME

Detected during execution: division by zero, out-of-range group index, a negative value where only a constant could have been checked earlier.

Scanner and parser errors are reported one at a time. A semantic error does not stop analysis of unrelated declarations, so a single eb check may report several.

Exit codes#

0

success

1

runtime error

2

compile error (scanner, parser, or semantic)

Constant versus runtime detection#

Several rules are checked at compile time when the offending expression is a constant and at runtime otherwise — a negative timeout (AG-80), a negative sched delta (SCHED-15), a negative resource capacity (RC-30). The same violation therefore appears in this catalog under two different phases depending on how it was written. This is deliberate: constant-folding the check is an optimization, not a change in what is legal.

The catalog#

What follows is generated from tests/suite by ./mk errors and verified by ./mk spec. It is not maintained by hand: the test suite is what pins the behavior, so a hand-copied catalog could only drift from it. To add an entry, add a test case.

Each entry gives the feature under test, the file it lives in, and the exact message the compiler is asserted to produce.

Scanner Errors#

10 cases, from tests/suite/invalid_scanner/. Every message below is the exact EXPECT-MSG the compiler is asserted to produce.

Illegal characterat_sign.eb

Scanner error, pos 5/6: illegal character '@'

Illegal character backtickbacktick.eb

Scanner error, pos 5/6: illegal character '`'

Invalid escape sequencebad_escape.eb

Scanner error, pos 5/8: invalid escape sequence '\q'

Number literal — decimal point requires leading digitdbl_no_leading_digit.eb

Scanner error, pos 5/6: number literal must have digit before decimal point

Number literal — digits required after decimal pointdbl_no_trailing_digit.eb

Scanner error, pos 5/6: number literal must have digit after decimal point

Illegal character $dollar_sign.eb

Scanner error, pos 5/6: illegal character '$'

Multiple decimal pointsmultiple_dots.eb

Scanner error, pos 5/6: unexpected character in number literal

Digit run immediately followed by identifier characternumber_then_letter.eb

Scanner error, pos 5/6: unexpected character in number literal

Trailing underscore in a number literaltrailing_underscore.eb

Scanner error, pos 5/6: unexpected character in number literal

Unterminated string literalunterminated_string.eb

Scanner error, pos 5/6: unterminated string literal

Parser Errors#

14 cases, from tests/suite/invalid_parser/. Every message below is the exact EXPECT-MSG the compiler is asserted to produce.

fn return type is mandatoryfn_missing_ret.eb

Compile error, pos 6/3: function return type is mandatory: expected ':' after ')'

Guard arm missing expression after ->guard_missing_expr.eb

Compile error, pos 7/1: expected expression after '->'

init block requires endinit_missing_end.eb

Compile error, pos 8/1: expected 'end' to close 'init' block

Declaration missing right-hand sidemissing_rhs.eb

Compile error, pos 6/1: expected expression, found EOF

obs_r with no variableobs_missing_var.eb

Compile error, pos 6/1: expected variable name after 'obs_r'

obs_r requires a variable name, not a reserved wordreserved_word_obs_r.eb

Compile error, pos 5/7: expected variable name after 'obs_r'

Reserved word used as identifierreserved_word_run.eb

Compile error, pos 5/1: 'run' is a reserved word and cannot be used as an identifier

resource capacity type must be intresource_non_int_type.eb

Compile error, pos 5/1: resource capacity type must be 'int'

rsc is only a parameter typersc_as_var_type.eb

Compile error, pos 5/5: type 'rsc' is only valid as a parameter type

run() requires braces around duration and nrunsrun_missing_braces.eb

Compile error, pos 6/7: expected '{' after run() arguments

run() duration and nruns are comma separatedrun_missing_comma.eb

Compile error, pos 6/10: expected ',' between duration and nruns

timeout is not a valid pi body itemtimeout_in_pi.eb

Compile error, pos 6/3: expected expression, found 'timeout'

timeout requires parenthesestimeout_missing_parens.eb

Compile error, pos 7/1: expected '(' after 'timeout'

Type keywords are lowercase onlytype_wrong_case.eb

Compile error, pos 5/4: unknown type 'INT'; expected int, dbl, str, or bool

Semantic Errors#

30 cases, from tests/suite/invalid_semantic/. Every message below is the exact EXPECT-MSG the compiler is asserted to produce.

Agent invocation is a statement, not an expressionagent_in_expression.eb

Compile error, pos 9/6: 'worker' is an agent and cannot be used in an expression

agent declared but no run()agent_no_run.eb

Compile error: model has agent declarations but no run() statement

dbl value cannot be assigned to an int variableassign_dbl_to_int.eb

Compile error, pos 5/10: cannot assign dbl to int variable 'x'

Assignment to an undeclared variableassign_without_decl.eb

Compile error, pos 5/1: assignment to undeclared variable 'x'; use ':=' to declare

claim is invalid inside an event bodyclaim_in_event.eb

Compile error, pos 7/3: 'claim' is only valid inside an agent body or init block

claim argument must be type rscclaim_not_rsc.eb

Compile error, pos 7/9: argument to 'claim' must be type rsc

fn body may not reference a pi by namefn_reads_pi.eb

Compile error, pos 7/10: a function body may not reference pi 'x'; pass its value as a parameter (FN-35)

for loop variable may not shadow an outer variablefor_shadow_outer.eb

Compile error, pos 7/5: 'i' is already declared

Guard arms must produce the same typeguard_arm_types.eb

Compile error, pos 6/6: guard arms produce different types: int and str (GUARD-40)

Guard expression requires a terminating default armguard_no_default.eb

Compile error, pos 6/6: guard expression requires a terminating '_' (or 'true') arm

if condition must be boolif_cond_not_bool.eb

Compile error, pos 7/4: if condition must be bool, got int

Series extraction on a non-observed variablelast_not_observed.eb

Compile error, pos 7/12: ':last' requires observation data; 'y' is not observed

Simulation model requires observationsmodel_no_obs.eb

Compile error: there are no observations in the model

No-horizon pi model without stop_r or haltno_horizon_no_stop.eb

Compile error: a run with no time horizon requires a stop_r or halt

pi and obs declared but no run()pi_no_run.eb

Compile error: model has pi declarations but no run() statement

More than one :randseed call is invalidrandseed_twice.eb

Compile error: more than one ':randseed' call is not permitted (EXEC-35)

Constant resource capacity below zerorc_capacity_negative.eb

Compile error, pos 5/1: resource capacity must be a non-negative integer; got -1

Redeclaration of an already-declared variableredeclare_var.eb

Compile error, pos 6/1: 'x' is already declared

release is invalid inside an event bodyrelease_in_event.eb

Compile error, pos 9/3: 'release' is only valid inside an agent body or init block

release argument must be type rscrelease_not_rsc.eb

Compile error, pos 9/11: argument to 'release' must be type rsc

run() requires a simulation declarationrun_with_no_sim.eb

Compile error: run() requires at least one pi, event, or agent declaration

Only event handlers may be scheduledsched_a_fn.eb

Compile error, pos 9/10: 'f' is a fn; only event handlers may be scheduled

Shadowing a module-level declaration is prohibitedshadow_module_var.eb

Compile error, pos 7/3: declaration of 'x' shadows a module-level declaration

stop_r at model level is invalidstop_r_model_level.eb

Compile error, pos 7/1: 'stop_r' is only valid inside pi, event, agent, or init bodies

stop_s inside an event body is invalidstop_s_in_event.eb

Compile error, pos 6/3: 'stop_s' is only valid at module level

timeout is invalid inside an event bodytimeout_in_event.eb

Compile error, pos 6/3: 'timeout' is only valid inside an agent body or init block

timeout is invalid inside a fn bodytimeout_in_fn.eb

Compile error, pos 6/3: 'timeout' is only valid inside an agent body or init block

Constant negative timeout deltatimeout_negative_const.eb

Compile error, pos 6/3: 'timeout' delta must be non-negative; got -1

Only one init block per programtwo_init_blocks.eb

Compile error: only one 'init' block is permitted per program

Reference to an undefined variableundefined_var.eb

Compile error, pos 5/6: undefined variable 'x'

Runtime Errors#

6 cases, from tests/suite/invalid_runtime/. Every message below is the exact EXPECT-MSG the compiler is asserted to produce.

Runtime group index out of declared rangegrp_index_out_of_range.eb

Runtime error: group index 4 is out of range 1..3

Integer division by zeroint_div_zero.eb

Runtime error: integer division by zero

:nth index out of range at runtimenth_out_of_range.eb

Runtime error: ':nth' index 6 is out of range 1..5

double release — the second finds nothing heldrelease_twice.eb

Runtime error: release of resource 'r', which this agent does not hold

releasing a resource the agent does not holdrelease_without_claim.eb

Runtime error: release of resource 'r', which this agent does not hold

Negative timeout delta at runtimetimeout_negative_runtime.eb

Runtime error: 'timeout' delta must be non-negative