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

supportsCopyMem can fail from macro context with tuples #24378

Open
Vindaar opened this issue Oct 28, 2024 · 0 comments · May be fixed by #24383
Open

supportsCopyMem can fail from macro context with tuples #24378

Vindaar opened this issue Oct 28, 2024 · 0 comments · May be fixed by #24383

Comments

@Vindaar
Copy link
Contributor

Vindaar commented Oct 28, 2024

Description

I just noticed helping someone with a problem with my https://github.com/Vindaar/forked syntax sugar library that in some cases std/typetraits supportsCopyMem can fail in a macro context.

The following code illustrates the problem

import std / [macros, typetraits]

macro forked*(body: typed): untyped = # typed or untyped does not matter
  result = quote do:
    type WIn = typeof(`body`)
    echo "Type? ", Win, " supportsCopyMem? ", Win.supportsCopyMem
    echo "Type? ", (int, Win), " supportsCopyMem? ", (int, Win).supportsCopyMem

forked:
  "foobar"

Note that the straightforward version without a macro:

type
  WIn = typeof("foo")
echo "Type? ", Win, " supportsCopyMem? ", Win.supportsCopyMem
echo "Type? ", (int, Win), " supportsCopyMem? ", (int, Win).supportsCopyMem

yields the correct output.

Nim Version

Nim Compiler Version 2.2.1 [Linux: amd64]
Compiled at 2024-10-28
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 15271dba2f4772a193f027d36c05b838dfff5bd4
active boot switches: -d:release -d:danger

(previously tested on a devel compiler from 2024/10/13 with the same behavior)

Current Output

Type? string supportsCopyMem? false
Type? (int, string) supportsCopyMem? true

Expected Output

Type? string supportsCopyMem? false
Type? (int, string) supportsCopyMem? false

Known Workarounds

No response

Additional Information

No response

Vindaar added a commit to Vindaar/forked that referenced this issue Oct 28, 2024
@ringabout ringabout self-assigned this Oct 29, 2024
ringabout added a commit that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants