Skip to content

Commit

Permalink
refactor(pointfree): address TS strictNullChecks flag
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 7, 2019
1 parent dd8806f commit 50bf59a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/pointfree-lang/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const nodeLoc = (node: ASTNode) =>
* @param ctx
*/
const resolveSym = (node: ASTNode, ctx: pf.StackContext) => {
const id = node.id;
const id = node.id!;
let w = ctx[2].__words[id] || ALIASES[id] || (<any>pf)[id];
if (!w) {
illegalArgs(`${nodeLoc(node)} unknown symbol: ${id}`);
Expand All @@ -47,7 +47,7 @@ const resolveSym = (node: ASTNode, ctx: pf.StackContext) => {
* @param ctx
*/
const resolveVar = (node: ASTNode, ctx: pf.StackContext) => {
const id = node.id;
const id = node.id!;
const v = ctx[2].__vars[id];
if (!v) {
illegalArgs(`${nodeLoc(node)} unknown var: ${id}`);
Expand All @@ -72,7 +72,7 @@ const resolveNode = (node: ASTNode, ctx: pf.StackContext): any => {
case NodeType.VAR_DEREF:
return resolveVar(node, ctx);
case NodeType.VAR_STORE:
return storevar(node.id);
return storevar(node.id!);
case NodeType.ARRAY:
return resolveArray(node, ctx);
case NodeType.OBJ:
Expand Down Expand Up @@ -267,7 +267,7 @@ const visitStore = (
ctx: pf.StackContext,
state: VisitorState
) => {
const id = node.id;
const id = node.id!;
if (state.word) {
ctx[0].push(storevar(id));
return ctx;
Expand Down Expand Up @@ -295,7 +295,7 @@ const visitWord = (
ctx: pf.StackContext,
state: VisitorState
) => {
const id = node.id;
const id = node.id!;
if (state.word) {
illegalState(
`${nodeLoc(node)}: can't define words inside quotations (${id})`
Expand Down
4 changes: 2 additions & 2 deletions packages/pointfree-lang/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Stubs for auto-generated parser module (using pegjs 0.10.+)
// To rebuild the parser run either: `yarn build` or `yarn peg`
export class SyntaxError {
message: string;
expected: string;
message!: string;
expected!: string;
found: any;
location: any;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/pointfree/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const op2v = (f: Fn2<any, any, any>) => (
illegalArgs("at least one arg must be an array");
}
}
stack[n] = c;
stack[n] = c!;
return ctx;
};

Expand Down Expand Up @@ -1250,6 +1250,7 @@ export const cases = (cases: IObjectOf<StackProc>) => (ctx: StackContext) => {
return $stackFn(cases.default)(ctx);
}
illegalState(`no matching case for: ${tos}`);
return ctx;
};

export const casesq = (ctx: StackContext) => {
Expand Down

0 comments on commit 50bf59a

Please sign in to comment.