Commit Graph

7 Commits

Author SHA1 Message Date
tersec e00fea1f6e
fix deprecation warnings from results; deprecate shims/io module; rm deprecated shims/os module (#223) 2024-06-27 11:48:32 +00:00
Etan Kissling 3159137d9a
workaround codegen error for `Base10.decode` (#111)
Calling `Base10.decode` may lead to different structures being generated
for use with `uint64`.

The one normally generated is:

```
struct tyObject_Result__559ckyoL0ZZBsNFIYXjaoeg {NIM_BOOL o;
union{
struct {NCSTRING e;
} _o_1;
struct {unsigned long long v;
} _o_2;
};
```

But sometimes, it may be generated as:

```
struct tyObject_Result__xZhi1m1g75ioXsKjx9bN5bg {NIM_BOOL o;
union{
struct {NCSTRING e;
} _o_1;
struct {NU64 v;
} _o_2;
};
```

When the latter is generated, the compiler throws with:
```
error: passing 'tyObject_Result__xZhi1m1g75ioXsKjx9bN5bg' (aka 'struct tyObject_Result__xZhi1m1g75ioXsKjx9bN5bg') to parameter of incompatible type 'tyObject_Result__559ckyoL0ZZBsNFIYXjaoeg' (aka 'struct tyObject_Result__559ckyoL0ZZBsNFIYXjaoeg')
```
for
```
proc getInt*(ht: HttpTables, key: string): uint64 =
  let res = Base10.decode(uint64, ht.getString(key))
  if res.isOk():
    res.get()    # This line may lead to the compiler error above
  else:
    0'u64
```

By passing the type as a generic param, the `unsigned long long` version
gets consistently generated / used regardless of include order.

Minimal POC to trigger the bug, from `nimbus-eth2` root:
```
echo 'import beacon_chain/conf, beacon_chain/sync/sync_manager' >x.nim
nim c -d:"libp2p_pki_schemes=secp256k1" -r x
```
Swapping include order (`conf` after `sync_manager`) works.
2023-08-25 00:04:33 +02:00
tersec 326ef09a46
remove dead code under Nim 1.6+ (#206) 2023-07-31 21:07:48 +00:00
Miran d37e77a72b
make it more Nim 1.4+ compatible (#131)
* make it more 1.6-compatible

* these changes are from 1.4 forward
2022-07-26 17:52:59 +00:00
Jacek Sieka 8a405309c6
enable styleCheck:usages (#93) 2021-12-02 16:24:02 +01:00
Eugene Kabanov ede0651741
Fix issue with `uint` type. (#79)
* Fix issue with `uint` type.
Add tests for `uint` type.

* Add decode tests for `uint` type.
2021-04-09 19:01:50 +03:00
Eugene Kabanov 6bcb21184a
Optimized and exception-less encoding/decoding procedures for decimal integers (#78)
* Optimized and exception-less encoding/decoding procedures for decimal integers.

* Add tests.

* Fix import path.

* Fix review comments.

* Code simplification.

* Make toBytes() allocation free.

* Do not perform conversion to signed type to avoid compiler's overflow checks.
2021-03-05 20:50:36 +02:00