diff --git a/src/construction_phase.js b/src/construction_phase.js index 88f7981..52e53c5 100644 --- a/src/construction_phase.js +++ b/src/construction_phase.js @@ -359,7 +359,7 @@ function execAssignement(ctx, ast) { } - if (!left.s) return ctx.throwError(ast, "variable. not defined yet"); + if ((!left)||(!left.s)) return ctx.throwError(ast, "variable. not defined yet"); if (left.t == "C") return execInstantiateComponet(ctx, left, ast.values[1], leftSels); if ((left.t == "S")&&( ["<--", "<==", "-->", "==>"].indexOf(ast.op) < 0)) return ctx.throwError(ast, "Cannot assign to a signal with `=` use <-- or <== ops"); @@ -444,14 +444,14 @@ function execInstantiateComponet(ctx, vr, fn, sels) { const templateName = fn.name; const template = ctx.templates[templateName]; - if (!template) return ctx.throwError("Invalid Template"); + if (!template) return ctx.throwError(fn, "Invalid Template"); const paramValues = []; for (let i=0; i< fn.params.length; i++) { const v = exec(ctx, fn.params[i]); if (ctx.error) return; for (let j=0; j