Weird -keyword-style prefix behaviour with modules

Alexey Egorov via Chicken-users <[email protected]> Tue, 17 Feb 2026 14:57:43 +0300
Newsgroups gmane.lisp.scheme.chicken
Message-ID <CALf3tGE4BD--E5zGxNZvhmr=hrj3dN3gihxGKMxVX=szVbvKyg@mail.gmail.com>
Hi. I have encountered a puzzling case. It can be demonstrated with
the following minimal example:

File `module.scm':

(module module (get-kw)
  (import scheme
          (chicken base))

  (define (get-kw)
    :prefix-kw))

File `main.scm':

(module main (main)
  (import
    scheme
    (chicken base)
    module)

  (define (main)
    (print (get-kw)))
  (main))

Compile and run as follows:

csc -K prefix -J -e -c -o module.o module.scm -unit module
csc -K prefix -c -o main.o main.scm
csc -K prefix -o test main.o module.o
./test

Result:
Error: Module `module' has unresolved identifiers

  Unknown identifier `:prefix-kw'
    In procedure `get-kw'

    Call history:

    <syntax>      (chicken.load#load-unit (##core#quote library)
(##core#quote #f) (##core#quote #f))
    <syntax>      (##core#quote library)
    <syntax>      (##core#quote #f)
    <syntax>      (##core#quote #f)
    <syntax>      (##core#require library chicken.base)
    <syntax>      (chicken.load#load-unit (##core#quote library)
(##core#quote #f) (##core#quote #f))
    <syntax>      (##core#quote library)
    <syntax>      (##core#quote #f)
    <syntax>      (##core#quote #f)
    <syntax>      (define (get-kw) |:prefix-kw|)
    <syntax>      (##core#begin (##core#ensure-toplevel-definition
get-kw) (##core#set! get-kw (##core#lambda () |:pre...
    <syntax>      (##core#ensure-toplevel-definition get-kw)
    <syntax>      (##core#undefined)
    <syntax>      (##core#set! get-kw (##core#lambda () |:prefix-kw|))
    <syntax>      (##core#lambda () |:prefix-kw|)
    <syntax>      [get-kw] (##core#begin |:prefix-kw|)    <--

If I use the regular keyword form, i.e. #:prefix-kw, it works as
expected. If I don't declare modules, it also works as expected.
I don't understand what's happening here. Possibly a bug?

Cheers,
Alexey.