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

Import/except doesn't work on devel #18986

Closed
PMunch opened this issue Oct 12, 2021 · 6 comments · Fixed by #19687
Closed

Import/except doesn't work on devel #18986

PMunch opened this issue Oct 12, 2021 · 6 comments · Fixed by #19687
Assignees

Comments

@PMunch
Copy link
Contributor

PMunch commented Oct 12, 2021

I came across this when trying to compile my epaper project with the devel compiler. I managed to boil it down to a sample like this:

import macros

converter Lit(x: uint): NimNode = newLit(x)

var x = 0.uint
echo "Found a ", x

The converter was originally from my macroutils package (I think I'm going to remove this converter, it keeps creating weird bugs). The original code uses Futhark, and in that package I import macroutils with import macroutils except Lit. First of should an imported converter trickle through two modules? Secondly shouldn't import macroutils except Lit stop those converters from getting imported into Futhark in the first place?

NOTE: The above fails both on devel and on stable, the bug is in the following snippets

Example

import macroutils except Lit
import macros

var x = 0.uint
echo "Found a ", x

Current Output

(5, 6) Error: type mismatch: got <string, uint>
but expected one of:
proc echo(x: varargs[typed, `$`])
  first type mismatch at position: 2
  required type for x: varargs[typed]
  but expression 'x' is of type: uint

expression: echo "Found a ", x

Expected Output

Found a 0
unclechu added a commit to unclechu/nixos-config that referenced this issue Dec 4, 2021
There was a confirmed regression in Nim 1.6.0
nim-lang/Nim#18986
@unclechu
Copy link

unclechu commented Dec 4, 2021

nim-dbus packages stops working in 1.6.0 because of this line:

https://github.com/zielmicha/nim-dbus/blob/74ec59f1813ae701764426c4ea0f11e092aefbe6/dbus/private/bus.nim#L3

converter toBool(x: dbus_bool_t): bool = x != 0

Any further attempt to convert uint32 to string fails with:

/build/invert-window-colors-nim/app.nim:133:29 Error: ambiguous call; both dollars.$(x: bool) [proc declared in /nix/store/yl80s2wgj1zza5n8c8x96y8ym95vx5v2-nim-unwrapped-1.6.0/nim/lib/system/dollars.nim:34:6] and dollars.$(x: uint64) [proc declared in /nix/store/yl80s2wgj1zza5n8c8x96y8ym95vx5v2-nim-unwrapped-1.6.0/nim/lib/system/dollars.nim:18:6] match for: (uint32)

@unclechu
Copy link

unclechu commented Dec 4, 2021

/build/invert-window-colors-nim/app.nim:162:62 Error: type mismatch: got <string, uint32>
but expected one of:
func format(formatstr: string; a: varargs[string, `$`]): string
  first type mismatch at position: 2
  required type for a: varargs[string]
  but expression 'childWnd' is of type: uint32

expression: format("Parent window id for \'$1\' not found!", childWnd)

@unclechu
Copy link

unclechu commented Feb 9, 2022

@PMunch I took Nim 1.6.2 from nixos-unstable NixOS channel. My program was successfully compiled with no changes and works as before. I think this regression ca be considered as fixed and the issue can be closed?

unclechu added a commit to unclechu/nixos-config that referenced this issue Feb 9, 2022
Use Nim 1.6.2 from nixos-unstable channel where
nim-lang/Nim#18986 is fixed.
unclechu added a commit to unclechu/nixos-config that referenced this issue Feb 9, 2022
Use Nim 1.6.2 from nixos-unstable channel where
nim-lang/Nim#18986 is fixed.
@SolitudeSF
Copy link
Contributor

SolitudeSF commented Mar 23, 2022

still broken on devel (731eabc)

@PMunch
Copy link
Contributor Author

PMunch commented Apr 6, 2022

@xflywind, I saw you pinged me on Discord about this issue. Please try to keep everything in this issue, makes it easier to find and track messages :) I don't have a test case in Futhark unfortunately. Tried to build the project I mentioned above again now and I seem to have worked around this problem in Futhark somehow.

@ringabout
Copy link
Member

I see, thanks

Araq pushed a commit that referenced this issue Apr 6, 2022
* fix #18986; Import/except doesn't work on devel [backport: 1.6]

* add testcase
narimiran pushed a commit that referenced this issue Apr 6, 2022
* fix #18986; Import/except doesn't work on devel [backport: 1.6]

* add testcase

(cherry picked from commit 5a995ff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants