mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
error recovery!
This commit is contained in:
parent
c0c08488ba
commit
ef04f21100
18 changed files with 799 additions and 366 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Crate, DepCrate, Final, Item, ItemId, Phase } from "./ast";
|
||||
import { Span } from "./error";
|
||||
import { ErrorHandler, Span } from "./error";
|
||||
import { Ids, unwrap } from "./utils";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
|
@ -20,6 +20,7 @@ export type CrateLoader = (
|
|||
* dependencies (which also use the same context) do not care about that.
|
||||
*/
|
||||
export class GlobalContext {
|
||||
public error: ErrorHandler = new ErrorHandler();
|
||||
public finalizedCrates: Crate<Final>[] = [];
|
||||
public crateId: Ids = new Ids();
|
||||
|
||||
|
|
@ -38,6 +39,17 @@ export class GlobalContext {
|
|||
allCrates.find((crate) => crate.id === id.crateId),
|
||||
);
|
||||
|
||||
if (crate.fatalError) {
|
||||
return {
|
||||
kind: "error",
|
||||
defPath: [],
|
||||
err: crate.fatalError,
|
||||
id: new ItemId(crate.id, 0),
|
||||
name: "",
|
||||
span: Span.startOfFile(crate.rootFile),
|
||||
};
|
||||
}
|
||||
|
||||
if (id.itemIdx === 0) {
|
||||
const contents: Item<P>[] | Item<Final>[] = crate.rootItems;
|
||||
// Typescript does not seem to be able to understand this here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue