summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2021-05-30 23:55:51 +0200
committerGitHub <noreply@github.com>2021-05-30 23:55:51 +0200
commit50e98e6efaca05b60b33db0c878f04951a43b3b8 (patch)
treee1db24dd023afdd4d949c6c53c042d5f96976e68
parente2ab08603db6499063b3ff0f16776b4ed20c36f0 (diff)
downloadNim-50e98e6efaca05b60b33db0c878f04951a43b3b8.tar.gz
hashes for refs should be an opt-in feature (#18098)
-rw-r--r--changelog.md17
-rw-r--r--lib/pure/hashes.nim2
-rw-r--r--tests/collections/ttables.nim1
-rw-r--r--tests/stdlib/thashes.nim1
4 files changed, 16 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index 809728b16..279ba38dd 100644
--- a/changelog.md
+++ b/changelog.md
@@ -50,8 +50,9 @@
 - On POSIX systems, we now ignore `SIGPIPE` signals, use `-d:nimLegacySigpipeHandler`
   for previous behavior.
 
-- `hashes.hash` now supports `object` and `ref` (can be overloaded in user code).
-  For a transition period, use `-d:nimLegacyNoHashRef` to avoid defining `hash(ref)`.
+- `hashes.hash` can now support `object` and `ref` (can be overloaded in user code),
+  if `-d:nimEnableHashRef` is used.
+
 - `hashes.hash(proc|ptr|ref|pointer)` now calls `hash(int)` and honors `-d:nimIntHash1`,
   `hashes.hash(closure)` has also been improved.
 
@@ -82,7 +83,9 @@
   other defines.
 
 
+
 ## Standard library additions and changes
+
 - Added support for parenthesized expressions in `strformat`
 
 - Fixed buffer overflow bugs in `net`
@@ -99,7 +102,6 @@
   the OpenSSL DLLs (e.g. libssl-1_1-x64.dll, libcrypto-1_1-x64.dll) you
   now also need to ship `cacert.pem` with your `.exe` file.
 
-
 - Make `{.requiresInit.}` pragma to work for `distinct` types.
 
 - Added a macros `enumLen` for returning the number of items in an enum to the
@@ -324,6 +326,8 @@
 
 - Fixed premature garbage collection in asyncdispatch, when a stack trace override is in place.
 
+
+
 ## Language changes
 
 - `nimscript` now handles `except Exception as e`.
@@ -368,6 +372,8 @@
 
 - `typeof(voidStmt)` now works and returns `void`.
 
+
+
 ## Compiler changes
 
 - Added `--declaredlocs` to show symbol declaration location in messages.
@@ -394,7 +400,8 @@
 - TLS: OSX now uses native TLS (`--tlsEmulation:off`), TLS now works with importcpp non-POD types,
   such types must use `.cppNonPod` and `--tlsEmulation:off`should be used.
 
-- Now array literals(JS backend) uses JS typed arrays when the corresponding js typed array exists, for example `[byte(1), 2, 3]` generates `new Uint8Array([1, 2, 3])`.
+- Now array literals(JS backend) uses JS typed arrays when the corresponding js typed array exists,
+  for example `[byte(1), 2, 3]` generates `new Uint8Array([1, 2, 3])`.
 
 - docgen: rst files can now use single backticks instead of double backticks and correctly render
   in both rst2html (as before) as well as common tools rendering rst directly (e.g. github), by
@@ -426,6 +433,8 @@
   the official Nim style guide. To be enabled, this has to be combined either
   with `--styleCheck:error` or `--styleCheck:hint`.
 
+
+
 ## Tool changes
 
 - The rst parser now supports markdown table syntax.
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim
index f61fbdf2b..46b4fc948 100644
--- a/lib/pure/hashes.nim
+++ b/lib/pure/hashes.nim
@@ -236,7 +236,7 @@ proc hash*[T](x: ptr[T]): Hash {.inline.} =
     assert cast[pointer](a[0].addr).hash == a[0].addr.hash
   hash(cast[pointer](x))
 
-when not defined(nimLegacyNoHashRef):
+when defined(nimEnableHashRef):
   proc hash*[T](x: ref[T]): Hash {.inline.} =
     ## Efficient `hash` overload.
     runnableExamples:
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim
index 638f4241b..751509062 100644
--- a/tests/collections/ttables.nim
+++ b/tests/collections/ttables.nim
@@ -8,6 +8,7 @@ And we get here
 '''
 joinable: false
 targets: "c cpp js"
+matrix: "-d:nimEnableHashRef"
 """
 
 # xxx wrap in a template to test in VM, see https://github.com/timotheecour/Nim/issues/534#issuecomment-769565033
diff --git a/tests/stdlib/thashes.nim b/tests/stdlib/thashes.nim
index 46576ef12..1e9b02d0c 100644
--- a/tests/stdlib/thashes.nim
+++ b/tests/stdlib/thashes.nim
@@ -1,5 +1,6 @@
 discard """
   targets: "c cpp js"
+  matrix: "-d:nimEnableHashRef"
 """
 
 import std/hashes