Comparing version 0.0.3-17 to 0.0.3-18
@@ -109,2 +109,3 @@ "use strict"; | ||
return imports.modules | ||
.filter((module) => module.name !== "globalThis") | ||
.map((module) => { | ||
@@ -111,0 +112,0 @@ if (module.namespace === "Relative") { |
@@ -391,3 +391,3 @@ "use strict"; | ||
if (!typeExistsInNamespace(block.type, typedBlocks, imports)) { | ||
return result_1.Err(`Type ${typeToString(block.type)} did not exist in the namespace.`); | ||
return result_1.Err(`Type ${typeToString(block.type)} did not exist in the namespace`); | ||
} | ||
@@ -404,5 +404,14 @@ const inferredRes = inferType(block.value, typedBlocks); | ||
case "Function": { | ||
const notExistingErrors = []; | ||
if (!typeExistsInNamespace(block.returnType, typedBlocks, imports)) { | ||
return result_1.Err(`Type ${typeToString(block.returnType)} did not exist in the namespace.`); | ||
notExistingErrors.push(`Type ${typeToString(block.returnType)} did not exist in the namespace`); | ||
} | ||
for (const arg of block.args) { | ||
if (!typeExistsInNamespace(arg.type, typedBlocks, imports)) { | ||
notExistingErrors.push(`Type ${typeToString(arg.type)} did not exist in the namespace`); | ||
} | ||
} | ||
if (notExistingErrors.length > 0) { | ||
return result_1.Err(notExistingErrors.join("\n")); | ||
} | ||
const inferredRes = inferType(block.body, typedBlocks); | ||
@@ -412,6 +421,6 @@ if (inferredRes.kind === "err") | ||
const inferred = inferredRes.value; | ||
if (isSameType(block.returnType, inferred, false)) { | ||
return result_1.Ok(block.returnType); | ||
if (!isSameType(block.returnType, inferred, false)) { | ||
return result_1.Err(`Expected \`${typeToString(block.returnType)}\` but got \`${typeToString(inferred)}\` in the body of the function`); | ||
} | ||
return result_1.Err(`Expected \`${typeToString(block.returnType)}\` but got \`${typeToString(inferred)}\` in the body of the function`); | ||
return result_1.Ok(block.returnType); | ||
} | ||
@@ -418,0 +427,0 @@ case "UnionType": |
{ | ||
"name": "derw", | ||
"version": "0.0.3-17", | ||
"version": "0.0.3-18", | ||
"description": "An Elm-inspired language that transpiles to TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -527,3 +527,3 @@ # derw | ||
git clone https://github.com/eeue56/derw-syntax | ||
git clone https://github.com/derw-lang/derw-syntax | ||
cp -r derw-syntax ~/.vscode/extensions/derw-syntax-0.0.1 | ||
@@ -533,4 +533,13 @@ | ||
# VScode Language server | ||
``` | ||
git clone https://github.com/derw-lang/derw-language-server | ||
cp -r derw-language-server ~/.vscode/extensions/derw-language-server-0.0.1 | ||
``` | ||
# Name | ||
derw which means oak. Oak is one of the native trees in Wales, famous for it's long life, tall stature, and hard, good quality wood. An English speaker might pronounce it as "deh-ru". |
@@ -143,2 +143,3 @@ import { | ||
return imports.modules | ||
.filter((module) => module.name !== "globalThis") | ||
.map((module) => { | ||
@@ -145,0 +146,0 @@ if (module.namespace === "Relative") { |
@@ -597,3 +597,3 @@ import { Err, Ok, Result } from "@eeue56/ts-core/build/main/lib/result"; | ||
block.type | ||
)} did not exist in the namespace.` | ||
)} did not exist in the namespace` | ||
); | ||
@@ -617,12 +617,28 @@ } | ||
case "Function": { | ||
const notExistingErrors = [ ]; | ||
if ( | ||
!typeExistsInNamespace(block.returnType, typedBlocks, imports) | ||
) { | ||
return Err( | ||
notExistingErrors.push( | ||
`Type ${typeToString( | ||
block.returnType | ||
)} did not exist in the namespace.` | ||
)} did not exist in the namespace` | ||
); | ||
} | ||
for (const arg of block.args) { | ||
if (!typeExistsInNamespace(arg.type, typedBlocks, imports)) { | ||
notExistingErrors.push( | ||
`Type ${typeToString( | ||
arg.type | ||
)} did not exist in the namespace` | ||
); | ||
} | ||
} | ||
if (notExistingErrors.length > 0) { | ||
return Err(notExistingErrors.join("\n")); | ||
} | ||
const inferredRes = inferType(block.body, typedBlocks); | ||
@@ -632,13 +648,13 @@ if (inferredRes.kind === "err") return inferredRes; | ||
if (isSameType(block.returnType, inferred, false)) { | ||
return Ok(block.returnType); | ||
if (!isSameType(block.returnType, inferred, false)) { | ||
return Err( | ||
`Expected \`${typeToString( | ||
block.returnType | ||
)}\` but got \`${typeToString( | ||
inferred | ||
)}\` in the body of the function` | ||
); | ||
} | ||
return Err( | ||
`Expected \`${typeToString( | ||
block.returnType | ||
)}\` but got \`${typeToString( | ||
inferred | ||
)}\` in the body of the function` | ||
); | ||
return Ok(block.returnType); | ||
} | ||
@@ -645,0 +661,0 @@ |
790819
22718
544