Skip to content

Commit

Permalink
use convert(T,x)::T for all declared return types
Browse files Browse the repository at this point in the history
before, the type assert was not included for short functions
  • Loading branch information
JeffBezanson committed Oct 13, 2016
1 parent 6839451 commit 66f5abf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/julia-syntax.scm
Expand Up @@ -185,8 +185,8 @@
val))))
`(,(car body) ,@meta
,(if (return? val)
`(return (call (top convert) ,rett ,(cadr val)))
`(call (top convert) ,rett ,val)))
`(return ,(convert-for-type-decl (cadr val) rett))
(convert-for-type-decl val rett)))
(let ((R (make-ssavalue)))
`(,(car body) ,@meta
(= ,R ,rett)
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Expand Up @@ -4404,6 +4404,11 @@ function f17613_2(x)::Float64
end
@test isa(f17613_2(1), Float64)

type A1090 end
Base.convert(::Type{Int}, ::A1090) = "hey"
f1090()::Int = A1090()
@test_throws TypeError f1090()

# issue #16783
function f16783()
T = UInt32
Expand Down

0 comments on commit 66f5abf

Please sign in to comment.