# Illegal use of syntax value at phase 1

**URL:** <https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983>\
**Category:** General\
**Created:** [June 8, 2023, 5:16pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983 "2023-06-08T17:16:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [June 8, 2023, 5:16pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/1 "2023-06-08T17:16:49Z")

</div>

hello,

i have this strange error, related with SRFI 105 (infix curly expression) i admit but the error comes from Racket language not the SRFI 105 reader.

In this macro (i quoted the body for debug) :

```scheme
(define-syntax $bracket-apply$
  (syntax-rules ()
    
    ((_ container index)
    
     (cond ((vector? container) '(if (equal? (quote :) (quote index))
				    container ;; return the vector
				    (vector-ref container index))) ;; return an element of the vector
	   ((hash-table? container) (hash-table-ref container index))
	   ((string? container) (string-ref container index))
	   (else (array-ref container index))))

```

and when testing i got this error:

```scheme
Welcome to DrRacket, version 8.9 [cs].
Language: reader "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/SRFI/SRFI-105-toplevel.rkt", with debugging; memory limit: 8192 MB.
> {z <+ #(1 2 3 4 5)}
'#(1 2 3 4 5)
> {z[2]}
'(if (equal? ': '2) z (vector-ref z 2))
> {z[:]}
:: illegal use of syntax
  value at phase 1: #<generator> in: :
> (define (:) 7)
> (:)
7
> '{z[:]}
'($bracket-apply$ z :)
> ($bracket-apply$ z :)
'(if (equal? ': ':) z (vector-ref z :))

```

you will notice there is no error if i use prefix syntax ,error is only when the reader SRFI 105 is used in {z[:]} , error is related with colon : but does not come from reader itself, : does not seems to be a reserved character in Racket.

I do not understand, so any help is greatly appreciated...

Regards,

Damien

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [June 8, 2023, 5:34pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/2 "2023-06-08T17:34:31Z")

</div>

note that the same code works in Guile :

```scheme
scheme@(guile-user)> (use-modules (Scheme+))
;;; note: source file /usr/local/share/guile/site/3.0/Scheme+.scm
;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/Scheme+.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /usr/local/share/guile/site/3.0/Scheme+.scm
;;; note: source file /usr/local/share/guile/site/3.0/growable-vector.scm
;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/growable-vector.scm.go
;;; compiling /usr/local/share/guile/site/3.0/growable-vector.scm
;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/growable-vector.scm.go
;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/Scheme+.scm.go
scheme@(guile-user)> {z <+ #(1 2 3 4 5)}
$1 = #(1 2 3 4 5)
scheme@(guile-user)> {z[2]}
$2 = 3
scheme@(guile-user)> {z[:]}
;;; <stdin>:4:3: warning: possibly unbound variable `:'
$3 = #(1 2 3 4 5)

```

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [June 8, 2023, 5:40pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/3 "2023-06-08T17:40:40Z")

</div>

i suppose the racket behavior has something to see with the infix reader that use this at beginning:

```scheme
(require syntax/strip-context)

(provide (rename-out [literal-read read]
                     [literal-read-syntax read-syntax]))

(define (literal-read in)
  (syntax->datum
   (literal-read-syntax #f in)))
 
(define (literal-read-syntax src in)
  
  (define lst-code (process-input-code-tail-rec in))

  (strip-context `(module anything racket/load ,@lst-code))) ;; this force a TOPLEVEL behavior !

```

i tried to remove the toplevel behavior with removing racket/load and using racket but it change nothing, perheaps the concernis with (require syntax/strip-context)

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [June 8, 2023, 5:58pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/4 "2023-06-08T17:58:59Z")

</div>

ok replacing colon by another character like O make it works:

```scheme
Welcome to DrRacket, version 8.9 [cs].
Language: reader "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/SRFI/SRFI-105-toplevel.rkt", with debugging; memory limit: 8192 MB.
> {z <+ #(1 2 3 4 5)}
'#(1 2 3 4 5)
> {z[O]}
'#(1 2 3 4 5)
> 

```

but still no explanation

i want to use : like in python ,any idea?

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [June 8, 2023, 6:27pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/5 "2023-06-08T18:27:12Z")

</div>

I think what's happening is that `:` is already bound to an identifier that is a syntax error when used by itself. But it's hard to tell without being able to run your programs.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [June 8, 2023, 7:25pm UTC](https://racket.discourse.group/t/illegal-use-of-syntax-value-at-phase-1/1983/6 "2023-06-08T19:25:09Z")

</div>

yes you are right, i was using the SRFI 42 Eager Comprehensions and the first thing defined in is the colon : defined in SRFI 42.

[https://srfi.schemers.org/srfi-42/srfi-42.html](https://srfi.schemers.org/srfi-42/srfi-42.html)

for syntax like this:

```scheme
(list-ec (: i 5) (* i i)) => (0 1 4 9 16)

```

this is in conflict with my syntax.

thank you very much , this solve the problem.

Regards,

Damien
