Skip to content

Commit

Permalink
Fix Promise<void> in non-async function
Browse files Browse the repository at this point in the history
Fixes #814
  • Loading branch information
edemaine committed Nov 22, 2023
1 parent 2bcb609 commit 6449078
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,8 @@ FunctionSignature
async,
generator,
modifier: {
async: !async.length,
generator: !generator.length,
async: !!async.length,
generator: !!generator.length,
},
block: null,
children: !parameters.implicit
Expand All @@ -1629,10 +1629,12 @@ FunctionExpression

if (hasAwait(block) && !signature.async.length) {
signature.async.push("async ")
signature.modifier.async = true
}

if (hasYield(block) && !signature.generator.length) {
signature.generator.push("*")
signature.modifier.generator = true
}

// Attach the block
Expand Down
22 changes: 22 additions & 0 deletions test/function.civet
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,28 @@ describe "function", ->
})
"""

testCase """
no async Promise<void>
---
(x): Promise<void> ->
fetch x
---
(function(x): Promise<void> {
return fetch(x)
})
"""

testCase """
no async Promise<void> longhand
---
function(x): Promise<void>
fetch x
---
(function(x): Promise<void> {
return fetch(x)
})
"""

testCase """
nested anonymous function
---
Expand Down

0 comments on commit 6449078

Please sign in to comment.