diff --git a/compiler/forget/packages/playground/app/layout.tsx b/compiler/forget/packages/playground/app/layout.tsx index 88cf805212..d40615681d 100644 --- a/compiler/forget/packages/playground/app/layout.tsx +++ b/compiler/forget/packages/playground/app/layout.tsx @@ -37,7 +37,7 @@ export default function RootLayout({ crossOrigin="anonymous" /> - {children} + {children} ); } diff --git a/compiler/forget/packages/playground/components/Editor/Input.tsx b/compiler/forget/packages/playground/components/Editor/Input.tsx index 75f67c1558..df96ad2e17 100644 --- a/compiler/forget/packages/playground/components/Editor/Input.tsx +++ b/compiler/forget/packages/playground/components/Editor/Input.tsx @@ -98,7 +98,7 @@ export default function Input({ errors }: Props) {
{/* Restrict MonacoEditor's height, since the config autoLayout:true will grow the editor to fit within parent element */} -
+
} - | { kind: "err"; error: CompilerError }; + | { + kind: "err"; + results: Map; + error: CompilerError; + }; type Props = { store: Store; @@ -48,7 +52,6 @@ function tabify(source: string, compilerOutput: CompilerOutput) { const reorderedTabs = new Map(); const concattedResults = new Map(); let topLevelFnDecls: Array = []; - if (compilerOutput.kind === "err") return reorderedTabs; // Concat all top level function declaration results into a single tab for each pass for (const [passName, results] of compilerOutput.results) { for (const result of results) { @@ -152,21 +155,28 @@ function Output({ store, compilerOutput }: Props) { [store.source, compilerOutput] ); - if (compilerOutput.kind === "err") { - return ( -
-        {compilerOutput.error.toString()}
-      
- ); - } - return ( - + <> + + {compilerOutput.kind === "err" ? ( +
+
+

COMPILER ERRORS

+
+
+            {compilerOutput.error.toString()}
+          
+
+ ) : null} + ); } diff --git a/compiler/forget/packages/playground/components/Editor/index.tsx b/compiler/forget/packages/playground/components/Editor/index.tsx index a75b79b419..ebe59d98b2 100644 --- a/compiler/forget/packages/playground/components/Editor/index.tsx +++ b/compiler/forget/packages/playground/components/Editor/index.tsx @@ -57,16 +57,16 @@ function parseFunctions( } function compile(source: string): CompilerOutput { + const results = new Map(); + const upsert = (result: PrintedCompilerPipelineValue) => { + const entry = results.get(result.name); + if (Array.isArray(entry)) { + entry.push(result); + } else { + results.set(result.name, [result]); + } + }; try { - const results = new Map(); - const upsert = (result: PrintedCompilerPipelineValue) => { - const entry = results.get(result.name); - if (Array.isArray(entry)) { - entry.push(result); - } else { - results.set(result.name, [result]); - } - }; for (const fn of parseFunctions(source)) { for (const result of run(fn)) { const fnName = fn.node.id?.name ?? null; @@ -112,7 +112,7 @@ function compile(source: string): CompilerOutput { if (error.details == null) { error.details = []; } - return { kind: "err", error }; + return { kind: "err", results, error }; } } @@ -150,7 +150,7 @@ export default function Editor() { return ( <> -
+
-
+
diff --git a/compiler/forget/packages/playground/components/TabbedWindow.tsx b/compiler/forget/packages/playground/components/TabbedWindow.tsx index dadf5c281d..b1ab3aad19 100644 --- a/compiler/forget/packages/playground/components/TabbedWindow.tsx +++ b/compiler/forget/packages/playground/components/TabbedWindow.tsx @@ -15,8 +15,18 @@ export default function TabbedWindow(props: { tabsOpen: Set; setTabsOpen: (newTab: Set) => void; }): React.ReactElement { + if (props.tabs.size === 0) { + return ( +
+ No compiler output detected, see errors below +
+ ); + } return ( -
+
{Array.from(props.tabs.keys()).map((name) => { return ( {isShow ? ( -
+