Skip to content

Commit f0928fa

Browse files
committed
Allow returning a Promise in blocks without wrapping it again.
1 parent d6cffc1 commit f0928fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/type_checker.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Mint
2727
VOID_FUNCTION = Type.new("Function", [Variable.new("a")] of Checkable)
2828
TEST_CONTEXT = Type.new("Test.Context", [Variable.new("a")] of Checkable)
2929
STYLE_MAP = Type.new("Map", [STRING, STRING] of Checkable)
30+
PROMISE = Type.new("Promise", [Variable.new("a")] of Checkable)
3031

3132
getter records, scope, artifacts, formatter, web_components
3233

src/type_checkers/block.cr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ module Mint
1111
last =
1212
statements.last
1313

14+
last_type = cache[last]
15+
1416
if node.async?
15-
Type.new("Promise", [cache[last]] of Checkable)
17+
if Comparer.compare(last_type, PROMISE)
18+
last_type
19+
else
20+
Type.new("Promise", [cache[last]] of Checkable)
21+
end
1622
else
1723
cache[last]
1824
end

0 commit comments

Comments
 (0)