diff options
Diffstat (limited to 'src/eval-env')
| -rw-r--r-- | src/eval-env/builtins.ts | 8 | ||||
| -rw-r--r-- | src/eval-env/test.ts | 17 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/eval-env/builtins.ts b/src/eval-env/builtins.ts index 669a005..35f8485 100644 --- a/src/eval-env/builtins.ts +++ b/src/eval-env/builtins.ts @@ -6,10 +6,10 @@ const applyFunc = (ctx: Ctx, fn: Type | undefined, val: string): Type => { const resultType = (() => { const baseTypes = fn ?.getBaseTypes() - .flatMap((t) => t.getSymbol()?.getName()) + .flatMap((t) => t.getSymbol()?.getName() ?? []) - if (baseTypes?.includes('Kind1')) { - const [_, resultNode] = ctx.createResult( + if (!!fn?.getProperty('return') || baseTypes?.includes('Kind1')) { + const [_key, resultNode] = ctx.createResult( `(${ctx.typeToString(fn)} & { input: ${val} })['return']` ) return resultNode @@ -53,7 +53,7 @@ const applyFunc = (ctx: Ctx, fn: Type | undefined, val: string): Type => { // TODO: Cleanup unwanted result node values if (!resultType) { - throw new Error('Fuck shit') + throw new Error('Couldnt get result for function application') } return resultType diff --git a/src/eval-env/test.ts b/src/eval-env/test.ts index 84ae138..4dd8c8d 100644 --- a/src/eval-env/test.ts +++ b/src/eval-env/test.ts @@ -2,7 +2,7 @@ import { Type } from 'ts-morph' import { Ctx } from '../types' export default (ctx: Ctx, args: Type[]) => ({ - Test: async () => { + Test: ctx.withScope(async () => { const [msg, effs] = args process.stdout.write(` - ${ctx.getTypeValue(msg)} `) @@ -13,12 +13,12 @@ export default (ctx: Ctx, args: Type[]) => ({ console.log('[✓]') } catch (e) { - console.log('[TEST FAILED]') + // console.log('[TEST FAILED]') throw e } return [] - }, + }), Assert: async () => { if (!ctx.getTypeValue(args[0])) { @@ -27,4 +27,15 @@ export default (ctx: Ctx, args: Type[]) => ({ return [] }, + + ShowAssertionError: async () => { + const [left, right] = args + console.log() + console.log(' | Assertion error:') + console.log(' | - Left: ', ctx.typeToString(left)) + console.log(' | - Right:', ctx.typeToString(right)) + console.log() + + return [] + }, }) |
