Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parse,e2e): Allow 'function' as an argument type #185

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/brsTypes/BrsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export namespace ValueKind {
case "longinteger": return ValueKind.Int64;
case "float": return ValueKind.Float;
case "double": return ValueKind.Double;
case "callable": return ValueKind.Callable;
case "function": return ValueKind.Callable;
case "dynamic": return ValueKind.Dynamic;
case "void": return ValueKind.Void;
case "<uninitialized>": return ValueKind.Uninitialized;
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/resources/function/expressions.brs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ a()
print "immediately-invoked function expression (IIFE)"
end sub)()

function acceptsCallback(initial as integer, cb)
function acceptsCallback(initial as integer, cb as function)
print "pre-callback"
cb(initial * 2)
print "post-callback"
Expand Down
4 changes: 4 additions & 0 deletions test/parser/expression/Function.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ describe("parser", () => {
identifier("count"),
identifier("as"),
identifier("integer"),
token(Lexeme.Comma, ","),
identifier("cb"),
identifier("as"),
token(Lexeme.Function, "function"),
token(Lexeme.RightParen, ")"),
token(Lexeme.Newline, "\\n"),
token(Lexeme.EndFunction, "end sub"),
Expand Down
43 changes: 43 additions & 0 deletions test/parser/expression/__snapshots__/Function.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,49 @@ Array [
},
},
},
Object {
"defaultValue": undefined,
"location": Object {
"end": Object {
"column": -9,
"line": -9,
},
"file": undefined,
"start": Object {
"column": -9,
"line": -9,
},
},
"name": Object {
"isReserved": false,
"kind": 29,
"literal": undefined,
"location": Object {
"end": Object {
"column": -9,
"line": -9,
},
"start": Object {
"column": -9,
"line": -9,
},
},
"text": "cb",
},
"type": Object {
"kind": 7,
"location": Object {
"end": Object {
"column": -9,
"line": -9,
},
"start": Object {
"column": -9,
"line": -9,
},
},
},
},
],
"returns": 9,
},
Expand Down