Resolving/expanding syntax object in context of specific module

I am defining a macro in a rhombus module that produces legal shplait syntax and is intended to be accessed by a module written in shplait.

What is the most direct and/or preferred way to associate the shplait language module's lexical information with the produced syntax object so that its bindings (particularly for implicit forms) resolve to those exported by shplait during expansion?

To be concrete, I have def.rhm as

#lang rhombus/and_meta
meta: def stx = `add1(42)`
expr.macro 'add1_42': stx
export add1_42

and use.rhm defined as

#lang shplait
import: open: "def.rhm"
add1_42

which fails at expansion time with add1 unbound.

I presume the solution is a use of replace_scopes. I have tried

  1. 'add1(42)'.replace_scopes('sub1') where sub1 is exported by shplait, and
  2. 'add1(42)'.replace_scopes(ctx) where ctx is bound to a Syntax.local_literal in the scope of all of shplait's bindings.

Where am I going wrong?

You could locally import and open shplait around the compile-time definition of stx. That way, shaplit is in the environment of 'add1(42)'. I'm using meta -1 here to reverse the phase shift from being inside meta:

#lang rhombus/and_meta
meta:
  import:
    meta -1: shplait open
  def stx = 'add1(42)'
expr.macro 'add1_42': stx
export add1_42

Using 'add1(42)'.replace_scopes('sub1') doesn't help, because 'add(42)' and 'sub1' both have the same environment / scopes.

If you really just wanted add1, then you could more simply use

#lang rhombus/and_meta
import:
  shplait.add1
meta:
  def stx = 'add1("42")'
expr.macro 'add1_42': stx
export add1_42

But I imagine you're trying to get more bindings from shplait.

Oops, I meant to say stx.replace_scopes(…) as the syntax object is patched together and I end up with a reference to it.

In any case, the meta -1: did the trick.

Thanks for your help!