Skip to content

Commit

Permalink
Merge branch 'main' into nn-neq-guards
Browse files Browse the repository at this point in the history
  • Loading branch information
gafter authored Nov 13, 2024
2 parents 23f30d1 + eb6162f commit 35ed072
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ Otherwise `2` is the result.
* A pure type match (without another pattern) can be written as `::Type`.
* Types appearing in type patterns (`::Type`) and struct patterns (`Type(...)`) are bound at macro-expansion time in the context of the module containing the macro usage. As a consequence, you cannot use certain type expressions that would differ. For example, you cannot use a type parameter or a local variable containing a type. The generated code checks that the type is the same at evaluation time as it was at macro expansion time, and an error is thrown if they differ. If this rare incompatibility affects you, you can use `x where x isa Type` as a workaround. If the type is not defined at macro-expansion time, an error is issued.
* A warning is issued at macro-expansion time if a case cannot be reached because it is subsumed by prior cases.
* Versions prior to `2.0.0` treated unexpected expressions as interpolations. For example, a pattern of the form `a.b` would be evaluated at pattern-match time and compared to the input. Interpolations now require the `$` syntax: `$(a.b)`.
28 changes: 28 additions & 0 deletions test/matchtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,32 @@ end
end
end

@testset "Test the behavior of NaN values" begin
v = 0.0 / 0.0
@test @match v begin
x where x > 0 => false
x where x <= 0 => false
_ => true
end
@test @match v begin
x where x < 0 => false
x where x >= 0 => false
_ => true
end
@test @match v begin
x where x >= 0 => false
x where x < 0 => false
_ => true
end
@test @match v begin
x where x <= 0 => false
x where x > 0 => false
_ => true
end
@test @match v begin
x where x == 0 => false
x where x != 0 => true
end
end

end

0 comments on commit 35ed072

Please sign in to comment.