Skip to content

Identifier incorrectly allowed to be "both defined and imported" #8

@LiberalArtist

Description

@LiberalArtist

R6RS §7.1 says:

An identifier can be imported with the same local name from two or more libraries or for two levels from the same library only if the binding exported by each library is the same (i.e., the binding is defined in one library, and it arrives through the imports only by exporting and re-exporting). Otherwise, no identifier can be imported multiple times, defined multiple times, or both defined and imported.

Racket's R6RS language currently fails to enforce this requirement.

Consider the following library, saved in a file bug.sls:

#!r6rs
(library (bug)
  (export)
  (import (rnrs base))
  (define + 'plus))

Racket allows this library, but it is rejected (at least) by Chez Scheme (both upstream and Racket's variant):

philip@bastet:~/code/tmp$ racket bug.sls 
philip@bastet:~/code/tmp$ scheme bug.sls 
Chez Scheme Version 9.5.8
Copyright 1984-2022 Cisco Systems, Inc.

Exception: multiple definitions for + in body (library (bug) (export) (import (rnrs base)) (define + (quote plus))) at line 2, char 1 of bug.sls
philip@bastet:~/code/tmp$ guix shell --pure --container chez-scheme-for-racket -- scheme bug.sls
Chez Scheme Version 9.5.7.6
Copyright 1984-2021 Cisco Systems, Inc.

Exception: multiple definitions for + in body (library (bug) (export) (import (rnrs base)) (define + (quote plus))) at line 2, char 1 of bug.sls

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions