status-im / nim-eth

Common utilities for Ethereum
https://nimbus.status.im
Apache License 2.0
83 stars 31 forks source link

Ambiguous call error (utils.fromHex) when running tests from Nim 0.20.0 #76

Closed oskarth closed 4 years ago

oskarth commented 5 years ago

Running

nimble install
nimble test

I expect tests to pass without any additional special action.

Actual result seen below, appears to be some ambiguous function calls in nim-0.20.0 and nimcrypto-0.39.9

> nimble test
  Executing task test in /home/oskarth/git/nim-eth/eth.nimble

Running: tests/test_bloom

[Suite] Simple Bloom Filter tests
  [OK] incl proc
  [OK] int value

Running: tests/test_common

[Suite] rlp encoding
  [OK] receipt roundtrip

Running: tests/keyfile/test_keyfile
/home/oskarth/git/nim-eth/eth/keyfile/keyfile.nim(233, 23) Error: ambiguous call; both utils.fromHex(a: string) [declared in /home/oskarth/.nimble/pkgs/nimcrypto-0.3.9/nimcrypto/utils.nim(158, 6)] and strutils.fromHex(s: string) [declared in /home/oskarth/.choosenim/toolchains/nim-0.20.0/lib/pure/strutils.nim(1049, 6)] match for: (string)
stack trace: (most recent call last)
/tmp/nimblecache/nimscriptapi.nim(164, 16)
/home/oskarth/git/nim-eth/eth_31398.nims(103, 18) testTask
/home/oskarth/git/nim-eth/eth_31398.nims(35, 12) runKeyfileTests
/home/oskarth/git/nim-eth/eth_31398.nims(27, 8) runTest
/home/oskarth/.choosenim/toolchains/nim-0.20.0/lib/system/nimscript.nim(242, 7) exec
/home/oskarth/.choosenim/toolchains/nim-0.20.0/lib/system/nimscript.nim(242, 7) Error: unhandled exception: FAILED: nim c -r -d:release -d:chronicles_log_level=ERROR --verbosity:0 --hints:off --warnings:off tests/keyfile/test_keyfile
     Error: Exception raised during nimble script execution

Workaround

Downgrading to 0.9.16 with choosenim 0.9.16. appears to work.

kdeme commented 5 years ago

Yes, looks like strutils now also has a fromHex: https://github.com/nim-lang/Nim/commit/981f95757c4b312a4f3e4bc6d6d92b3734331e98

Easy fixable by using utils.fromHex or from strutils import ... construct. However, then we hit next issue in ./tests/p2p/test_enode:

Unhandled exception: assignment to discriminant changes object branch; compile with -d:nimOldCaseObjects for a transition period [FieldError]

That one looks like it will need some more investigation (at least for me). I'll pause this for now as there hasn't been much focus on moving to 0.20.0 for now (right?), and I'm not sure how far this will lead me :)

stefantalpalaru commented 5 years ago

'll pause this for now as there hasn't been much focus on moving to 0.20.0 for now (right?)

Been there, done that. I stopped when I hit this bug: https://github.com/nim-lang/Nim/issues/11414

Nim-0.20.0 is too buggy to target. Let's wait for the next version.

kdeme commented 4 years ago

fixed with https://github.com/status-im/nim-eth/pull/115