Skip to content

Strformat: undeclared identifier in quote do section. #8220

Closed
@mratsim

Description

@mratsim

It's currently very hard to use strformat module in a quote do section

Here is the ideal way to use it that does not work

import macros, strformat

macro foo(): untyped =
  result = quote do:
    let bar = "Hello, World"
    echo &"Let's interpolate {bar} in the string"

foo()

Here is the current way to make it work:

import macros, strformat

macro foo(): untyped =
  let workaround = newIdentNode("workaround")
  result = quote do:
    let `workaround` = "Hello, World"
    echo &"Let's interpolate {workaround} in the string"

foo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions