diff --git a/source/compiler/codegen/expression/helper.ts b/source/compiler/codegen/expression/helper.ts index 07be5c0..d66a1e8 100644 --- a/source/compiler/codegen/expression/helper.ts +++ b/source/compiler/codegen/expression/helper.ts @@ -1,4 +1,5 @@ import type * as Syntax from "~/bnf/syntax.d.ts"; +import { red } from "https://deno.land/std@0.201.0/fmt/colors.ts"; import { AssertUnreachable, LatentOffset } from "~/helper.ts"; import { BasePointerType, LinearType } from "~/compiler/codegen/expression/type.ts"; @@ -60,9 +61,15 @@ export function ResolveLinearType(ctx: Context, type: LinearType, ref: Reference if (strict) { const errs = type.getCompositionErrors(); if (errs) { - console.error(`Unable to compose value due to some arguments being uninitialized since: ${errs.map(x => x.start.toString()).join(", ")}\n` + const range = ref.clone(); + for (const err of errs) { + range.span(err); + } + + console.error(`${red("Error")}: Unable to compose value due to some arguments being uninitialized since: ${errs.map(x => x.start.toString()).join(", ")}\n` + errs.map(x => SourceView(ctx.file.path, ctx.file.name, x, true)).join("") - + SourceView(ctx.file.path, ctx.file.name, ref, false) + + SourceView(ctx.file.path, ctx.file.name, ref, true) + + ` ${ctx.file.name} ${range.toString()}\n` ); ctx.file.markFailure(); diff --git a/source/compiler/package.ts b/source/compiler/package.ts index 7261fc2..f2a2794 100644 --- a/source/compiler/package.ts +++ b/source/compiler/package.ts @@ -6,21 +6,23 @@ import { File } from "~/compiler/file.ts" export default class Package { project: Project; files: File[]; + name: string; cwd: string; failed: boolean; - constructor(project: Project, base: string) { + constructor(project: Project, base: string, name: string = "~") { this.project = project; this.failed = false; this.files = []; + + this.name = name; this.cwd = dirname(base); } import(filePath: string) { - const name = relative(this.cwd, filePath); const data = Deno.readTextFileSync(filePath); - const file = new File(this, filePath, name, data); + const file = new File(this, filePath, `${this.name}/${relative(this.cwd, filePath)}`, data); this.files.push(file); return file; diff --git a/source/parser.ts b/source/parser.ts index cf8c6ca..e09ba16 100644 --- a/source/parser.ts +++ b/source/parser.ts @@ -67,14 +67,14 @@ function SingleLine(path: string, name: string, range: ReferenceRange, compact?: line = line.trimStart(); pad -= line.length; - const margin = `${range.start.line} │ `; + const margin = ` ${range.start.line} │ `; const underline = "\n" + " ".repeat(margin.length + range.start.col - pad) + "^".repeat(Math.max(1, range.end.col - range.start.col)) + "\n"; const body = margin + line + underline; - return compact ? body : ` ${name}: ${range.toString()}\n`; + return compact ? body : `${body} ${name}: ${range.toString()}\n`; } function MultiLine(path: string, name: string, range: ReferenceRange, compact?: boolean) {