From 482ceb76dc0f77c5e5003e963ed1525cec57305e Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 29 Jul 2022 23:19:55 +0400 Subject: [PATCH 1/2] check expression type in viewer to mitigate the void bug --- .../SquiggleViewer/ExpressionViewer.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx b/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx index 1417fb28..9a3e266e 100644 --- a/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx +++ b/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx @@ -59,6 +59,13 @@ export const ExpressionViewer: React.FC = ({ expression, width, }) => { + if (typeof expression !== "object") { + return ( + + {() => `Unknown expression: ${expression}`} + + ); + } switch (expression.tag) { case "number": return ( @@ -281,10 +288,16 @@ export const ExpressionViewer: React.FC = ({ ); default: { return ( -
- No display for type: {" "} - {expression.tag} -
+ + {() => ( +
+ No display for type: {" "} + + {expression.tag} + +
+ )} +
); } } From 52bee6a0e36527b53394bd281247431f162095d1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 29 Jul 2022 23:35:11 +0400 Subject: [PATCH 2/2] fix EvVoid ts conversion --- packages/squiggle-lang/src/js/rescript_interop.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/squiggle-lang/src/js/rescript_interop.ts b/packages/squiggle-lang/src/js/rescript_interop.ts index 80548a7f..3dca8165 100644 --- a/packages/squiggle-lang/src/js/rescript_interop.ts +++ b/packages/squiggle-lang/src/js/rescript_interop.ts @@ -18,6 +18,7 @@ import { tagged, tag } from "./types"; // Raw rescript types. export type rescriptExport = + | 0 // EvVoid | { TAG: 0; // EvArray _0: rescriptExport[]; @@ -140,6 +141,10 @@ export function convertRawToTypescript( result: rescriptExport, environment: environment ): squiggleExpression { + if (typeof result === "number") { + // EvVoid + return tag("void", ""); + } switch (result.TAG) { case 0: // EvArray return tag(