Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashes for refs should be an opt-in feature #18098

Merged
merged 1 commit into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -80,7 +81,9 @@
other defines.



## Standard library additions and changes

- Added support for parenthesized expressions in `strformat`

- Fixed buffer overflow bugs in `net`
Expand All @@ -97,7 +100,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
Expand Down Expand Up @@ -322,6 +324,8 @@

- Fixed premature garbage collection in asyncdispatch, when a stack trace override is in place.



## Language changes

- `nimscript` now handles `except Exception as e`.
Expand Down Expand Up @@ -366,6 +370,8 @@

- `typeof(voidStmt)` now works and returns `void`.



## Compiler changes

- Added `--declaredlocs` to show symbol declaration location in messages.
Expand All @@ -392,7 +398,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
Expand Down Expand Up @@ -424,6 +431,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.
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/hashes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/collections/ttables.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/stdlib/thashes.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
discard """
targets: "c cpp js"
matrix: "-d:nimEnableHashRef"
"""

import std/hashes
Expand Down