Skip to content

Commit

Permalink
Merge pull request #105 from fink-lang/fix-runtime-call
Browse files Browse the repository at this point in the history
Fix runtime call
  • Loading branch information
kollhof authored Nov 16, 2020
2 parents 639fd2d + 091d8f2 commit 4a505e1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 32 deletions.
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/lang/call/call.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ transform_args = fn args, ctx:
map_with_ctx fn expr, arg_ctx:
match expr:
{type: 'empty'}:
[(identifier 'undefined'), ctx]
[(identifier 'undefined'), arg_ctx]
else:
transform expr, arg_ctx
collect_with_ctx ctx



transform_single_arg = fn [expr], ctx:
match expr:
{type: 'empty'}:
Expand Down
4 changes: 3 additions & 1 deletion src/lang/iterable/common.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ transform_with_runtime_lib = fn iter_fn, node, ctx:
callee: {type: 'ident', value : iter_fn}
args: seq:
rec:
type: 'fn'
type: 'block'
op: 'fn'
args: final_args
exprs: exprs
loc: node.loc
Expand All @@ -73,6 +74,7 @@ transform_with_runtime_lib = fn iter_fn, node, ctx:
...initial_values
loc: node.loc
ctx

[result, end_ctx]


Expand Down
10 changes: 10 additions & 0 deletions src/lang/iterable/map.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ describe 'map', fn:
to_match_snapshot


it 'handles initial args transform (ctx bug)', fn:
expect
fink2js '
foo = map item, acc:
true in spam
'
to_match_snapshot



describe 'custom runtime', fn:

it 'uses multiple custom runtimes', fn:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/iterable/map.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ exports[`map handles await 1`] = `
}"
`;

exports[`map handles initial args transform (ctx bug) 1`] = `
"import { _in_ } from \\"@fink/js-interop/runtime.js\\";
import { _map_ } from \\"@fink/js-interop/runtime.js\\";
export const foo = _map_((item, acc) => _in_(true, spam), 2, false, false, undefined);"
`;

exports[`map legacy compiles as flat map 1`] = `
"(function map(ˆitems_3) {
return {
Expand Down

0 comments on commit 4a505e1

Please sign in to comment.