Skip to content

Commit

Permalink
Test that internal constructor return type asserts are respected (Jul…
Browse files Browse the repository at this point in the history
…iaLang#47227)

On Julia 1.8, if the internal constructor's return value was typeasserted,
this assertion could be violated without an error. For example, in this case:

```julia
struct Foo
    x::Int
    Foo()::Nothing = new(1)
end
```

Running `Foo()` would not throw. This was inadvertently fixed in a later PR,
but not tested.
This PR adds a test case similar to the example above.
  • Loading branch information
jakobnissen authored Oct 22, 2022
1 parent 8bef4a7 commit fa9c137
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4859,6 +4859,13 @@ let a = Any[]
@test a == [10, 2]
end

# issue 47209
struct f47209
x::Int
f47209()::Nothing = new(1)
end
@test_throws MethodError f47209()

# issue #12096
let a = Val{Val{TypeVar(:_, Int)}},
b = Val{Val{x} where x<:Int}
Expand Down

0 comments on commit fa9c137

Please sign in to comment.