Skip to content

Remove re-definition of SomeSet #34

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

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

ee7
Copy link
Contributor

@ee7 ee7 commented Nov 12, 2021

Commit ebee42e ("A little cleanup around set types.", 2021-10-01)
added an exported definition of SomeSet that included the
built-in set type.

However, a typical Nim user is familiar with the definition of SomeSet
in the standard library of

SomeSet*[A] = HashSet[A] | OrderedSet[A]

and was thus likely to read the lines

proc parseHook*[T](s: string, i: var int, v: var SomeSet[T]) =

and

proc dumpHook*[T](s: var string, v: SomeSet[T]) =

and believe that jsony does not support the built-in set type.

This commit therefore removes the SomeSet re-definition, which also
means that jsony once again works with code like

import std/sets
import pkg/jsony

proc foo[T](s: SomeSet[T]) =
  discard

which successfully compiled with jsony 1.0.5 and earlier, but produced
an error with jsony 1.1.0 (2021-11-04):

    /tmp/foo.nim(4, 16) Error: ambiguous identifier: 'SomeSet' -- use one of the following:
      sets.SomeSet: SomeSet
      jsony.SomeSet: SomeSet

Support for the built-in set type was originally added by
commit 9a4f118 (2021-10-01).

Fixes: #33

Commit ebee42e ("A little cleanup around set types.", 2021-10-01)
added an exported definition of `SomeSet` that included the
built-in `set` type.

However, a typical Nim user is familiar with the definition of `SomeSet`
in the standard library of

    SomeSet*[A] = HashSet[A] | OrderedSet[A]

and was thus likely to read the lines

    proc parseHook*[T](s: string, i: var int, v: var SomeSet[T]) =

and

    proc dumpHook*[T](s: var string, v: SomeSet[T]) =

and believe that jsony does not support the built-in `set` type.

This commit therefore removes the `SomeSet` re-definition, which also
means that jsony once again works with code like

    import std/sets
    import pkg/jsony

    proc foo[T](s: SomeSet[T]) =
      discard

which successfully compiled with jsony 1.0.5 and earlier, but produced
an error with jsony 1.1.0 (2021-11-04):

    /tmp/foo.nim(4, 16) Error: ambiguous identifier: 'SomeSet' -- use one of the following:
      sets.SomeSet: SomeSet
      jsony.SomeSet: SomeSet

Support for the built-in `set` type was originally added by
commit 9a4f118 (2021-10-01).

Fixes: treeform#33
@treeform
Copy link
Owner

Thank you for the PR.

@ee7 ee7 deleted the remove-SomeSet-redefinition branch November 16, 2021 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jsony 1.1.0: surprising re-definition of 'SomeSet'; ambiguous identifer error
2 participants