Skip to content

Commit

Permalink
codegen: presume member type if object type known
Browse files Browse the repository at this point in the history
  • Loading branch information
CanadaHonk committed Feb 7, 2024
1 parent cbf3d06 commit 7928384
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/codeGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,10 @@ const getNodeType = (scope, node) => {
// hack: if something.length, number type
if (node.property.name === 'length') return TYPES.number;

// ts hack
if (scope.locals[node.object.name]?.metadata?.type === TYPES.string) return TYPES.string;
if (scope.locals[node.object.name]?.metadata?.type === TYPES._array) return TYPES.number;

if (scope.locals['#last_type']) return [ getLastType(scope) ];

// presume
Expand Down

0 comments on commit 7928384

Please sign in to comment.