From c413a1918775f8ecf83f3fd23cf39fd87f5bec3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hoffmann?= Date: Wed, 26 May 2021 01:11:45 +0200 Subject: [PATCH] make \minus equivalent to - operator #26193 --- NEWS.md | 1 + doc/src/manual/variables.md | 1 + src/flisp/julia_charmap.h | 1 + src/julia-parser.scm | 2 +- test/syntax.jl | 5 ++++- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 27074440b3b49..f36e8bff553d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,7 @@ Language changes * `macroexpand`, `@macroexpand`, and `@macroexpand1` no longer wrap errors in a `LoadError`. To reduce breakage, `@test_throws` has been modified so that many affected tests will still pass ([#38379]]. * The middle dot `·` (`\cdotp` U+00b7) and the Greek interpunct `·` (U+0387) are now treated as equivalent to the dot operator `⋅` (`\cdot` U+22c5) (#25157). +* The minus sign `−` (`\minus` U+2212) is now treated as equivalent to the hyphen-minus sign `-` (U+002d). Compiler/Runtime improvements ----------------------------- diff --git a/doc/src/manual/variables.md b/doc/src/manual/variables.md index 4461ee5c32afe..004efb92dc0e5 100644 --- a/doc/src/manual/variables.md +++ b/doc/src/manual/variables.md @@ -143,6 +143,7 @@ are treated as equivalent to the corresponding Greek letters. The middle dot `·` (U+00B7) and the Greek [interpunct](https://en.wikipedia.org/wiki/Interpunct) `·` (U+0387) are both treated as the mathematical dot operator `⋅` (U+22C5). +The minus sign `−` (U+2212) is treated as equivalent to the hyphen-minus sign `-` (U+002D). ## Stylistic Conventions diff --git a/src/flisp/julia_charmap.h b/src/flisp/julia_charmap.h index 7384df0c7f506..59f408ce012c9 100644 --- a/src/flisp/julia_charmap.h +++ b/src/flisp/julia_charmap.h @@ -6,4 +6,5 @@ static const uint32_t charmap[][2] = { { 0x00B5, 0x03BC }, // micro sign -> greek small letter mu { 0x00B7, 0x22C5 }, // middot char -> dot operator (#25098) { 0x0387, 0x22C5 }, // Greek interpunct -> dot operator (#25098) + { 0x2212, 0x002D }, // minus -> hyphen-minus (#26193) }; diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 1f594ff0a1414..17e8f27faf5a9 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -20,7 +20,7 @@ (define prec-pipe> '(|.\|>| |\|>|)) (define prec-colon (append! '(: |..|) (add-dots '(… ⁝ ⋮ ⋱ ⋰ ⋯)))) (define prec-plus (append! '($) - (add-dots '(+ - ¦ |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣)))) + (add-dots '(+ - − ¦ |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣)))) (define prec-times (add-dots '(* / ⌿ ÷ % & · · ⋅ ∘ × |\\| ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇ ⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻ ⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗ ⨟))) (define prec-rational (add-dots '(//))) (define prec-bitshift (add-dots '(<< >> >>>))) diff --git a/test/syntax.jl b/test/syntax.jl index d7e136f92dfcc..be2dfe0a8323f 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -819,7 +819,7 @@ let f = function (x; kw...) end # normalization of Unicode symbols (#19464) -let ε=1, μ=2, x=3, î=4, ⋅=5 +let ε=1, μ=2, x=3, î=4, ⋅=5, (-)=6 # issue #5434 (mu vs micro): @test Meta.parse("\u00b5") === Meta.parse("\u03bc") @test µ == μ == 2 @@ -832,6 +832,9 @@ let ε=1, μ=2, x=3, î=4, ⋅=5 # middot char · or · vs math dot operator ⋅ (#25098) @test Meta.parse("\u00b7") === Meta.parse("\u0387") === Meta.parse("\u22c5") @test (·) == (·) == (⋅) == 5 + # minus − vs hyphen-minus - (#26193) + @test Meta.parse("\u2212") === Meta.parse("\u002d") + @test (−) == (-) == 6 end # issue #8925