# \[Feature Request\] Improve error message for neglecting to (require (for-syntax racket/base))

**URL:** <https://racket.discourse.group/t/feature-request-improve-error-message-for-neglecting-to-require-for-syntax-racket-base/948>\
**Category:** Questions & Answers\
**Created:** [May 1, 2022, 5:31pm UTC](https://racket.discourse.group/t/feature-request-improve-error-message-for-neglecting-to-require-for-syntax-racket-base/948 "2022-05-01T17:31:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [May 1, 2022, 5:31pm UTC](https://racket.discourse.group/t/feature-request-improve-error-message-for-neglecting-to-require-for-syntax-racket-base/948/1 "2022-05-01T17:31:14Z")

</div>

See [[Feature Request] Improve error message for neglecting to (require (for-syntax racket/base)) · Issue #3912 · racket/racket · GitHub](https://github.com/racket/racket/issues/3912)  
I do not understand why (require (for-syntax racket/base)) is required.  
The following works:

```scheme
#lang racket
(define-syntax aap (syntax 'noot))

```

According to the docs syntax _syntax_ is exported from racket/base too,  
but the following does not work:

```scheme
#lang racket/base
(define-syntax aap (syntax 'noot))

```

With racket/base a require for syntax is required:

```scheme
#lang racket/base
(require (for-syntax (only-in racket/base syntax)))
(define-syntax aap (syntax 'noot))

```

This puzzles me. How come?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [May 1, 2022, 5:46pm UTC](https://racket.discourse.group/t/feature-request-improve-error-message-for-neglecting-to-require-for-syntax-racket-base/948/2 "2022-05-01T17:46:34Z")

</div>

It's due to phases.

The module `racket/base` exports `syntax` to phase 0.  
The expression of `(define-syntax id expr)` is evaluated in phase 1.  
So to import `syntax` for phase 1, an `(require (for-syntax racket/base))` is needed.

On the other hand (if I remember correctly) `racket` exports `syntax` to both phase 0 and 1.

In practice when I use `racket/base` and need to define a macro, I always add:

```
(require (for-syntax racket/base racket/syntax syntax/parse))

```

With respect to the error message: The current error message simply says `syntax` is unbound.  
It is possible to detect that is available in a different phase - so it could suggest to the user that an adding an import for the the correct phase might fix the problem.

---

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [May 1, 2022, 6:39pm UTC](https://racket.discourse.group/t/feature-request-improve-error-message-for-neglecting-to-require-for-syntax-racket-base/948/3 "2022-05-01T18:39:22Z")

</div>

Hello Soegaard  
Thanks for your prompt and clear answer.  
Saludos, Jos
