# Surprising identifier binding ambiguity error with nested splicing-local (possible bug)

**URL:** <https://racket.discourse.group/t/surprising-identifier-binding-ambiguity-error-with-nested-splicing-local-possible-bug/2912>\
**Category:** Questions & Answers\
**Created:** [May 10, 2024, 1:19pm UTC](https://racket.discourse.group/t/surprising-identifier-binding-ambiguity-error-with-nested-splicing-local-possible-bug/2912 "2024-05-10T13:19:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregr](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/gregr/32/1759_2.png) [@gregr](https://racket.discourse.group/u/gregr)\
**Post date:** [May 10, 2024, 1:19pm UTC](https://racket.discourse.group/t/surprising-identifier-binding-ambiguity-error-with-nested-splicing-local-possible-bug/2912/1 "2024-05-10T13:19:11Z")

</div>

I encountered a surprising identifier binding ambiguity error when using `splicing-local` within the body of another `splicing-local`. Am I misusing `splicing-local`, or is this a bug?

Here's a small reproduction of the problem:

```scheme
;;; splicing-bug.rkt
#lang racket/base
(require racket/splicing)

;; This one works.
;(splicing-local
; ((define one 0)
; (define (two) one))
; 3)

;; This one produces an error:
(splicing-local
  ()
  (splicing-local
    ((define one 0)
     (define (two) one))
    3))
;> racket splicing-bug.rkt
;splicing-bug.rkt:16:19: one: identifier's binding is ambiguous
; in: one
; context...:
; #(536 intdef-outside) #(537 intdef) #(538 intdef-outside)
; #(539 intdef) #(735 intdef-outside) #(736 intdef) #(747 local)
; #(748 intdef) [common scopes]
; matching binding...:
; #(one.1 #<module-path-index='splicing-bug[253]> 0)
; #(735 intdef-outside) #(736 intdef) [common scopes]
; matching binding...:
; local
; #(536 intdef-outside) #(537 intdef) #(538 intdef-outside)
; #(539 intdef) [common scopes]
; common scopes...:
; #(9 module) #(467 module splicing-bug) #(612 intdef)
; location...:
; splicing-bug.rkt:16:19

```

---

<div class="post-metadata">

**Author:** ![usao](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/usao/32/1375_2.png) [@usao](https://racket.discourse.group/u/usao)\
**Post date:** [May 14, 2024, 5:53am UTC](https://racket.discourse.group/t/surprising-identifier-binding-ambiguity-error-with-nested-splicing-local-possible-bug/2912/2 "2024-05-14T05:53:29Z")

</div>

A further oddity is that it works fine in an expression context:

```scheme
#lang racket/base
(require racket/splicing)

(#%expression
 (splicing-local []
   (splicing-local [(define one 0)
                    (define (two) one)]
     3)))

```

Yes, this definitely seems like a bug. I’ll open an issue and look into this at some point.
