Opened 7 years ago

Last modified 17 months ago

#1131 new defect

Kill ##sys#alias-global-hook with fire

Reported by: sjamaan Owned by:
Priority: major Milestone: 5.3
Component: unknown Version: 4.9.x
Keywords: Cc:
Estimated difficulty: insane


The whole concept is broken. Just by studying the code it's easy to come up with bug after bug.

Change History (10)

comment:1 Changed 7 years ago by sjamaan

Here's the first:

The following code will compile (or run, in csi). If the module definition for another is removed, it doesn't. Why? Because when another imports foo, ##sys#mark-imported-symbols will mark it as ##core#aliased, which means ##sys#alias-global-hook will simply pass it through whenever it's subsequently referenced.

(module foo (bar)
  (import scheme chicken)
  (define (bar x) (+ x 1)))

(module another ()
  (import chicken scheme foo)
  (define lala bar))

(module whoops (lala2)
  (import chicken scheme)
  (define lala2 foo#bar))

(import whoops)
(print (lala2 1))

The question is whether a fully qualified module identifier should work within another module regardless of whether it's been imported. This part should be the first to clean up, because ##core#aliased is only used in a handful of places. Unfortunately it's a bit of a mindfuck, because it is really used all over the place, through ##sys#global-alias-hook.

comment:2 Changed 7 years ago by sjamaan

Ideally, we'd also remove ##sys#mark-imported-symbols while we're at it: it's totally unneccessary, because whether a symbol is imported is an aspect of a particular module, not a global status (if we ignore the toplevel).

comment:3 Changed 7 years ago by sjamaan

Another inconsistency:

(module bar (x)
  (import scheme)
  (define x 1))

(module foo ()
  (import chicken)
  (print (#%+ bar#x 1)))

The above program fails with Warning: reference to possibly unbound identifier `bar#x'. If we add bar to the import list (or remove the reference) it will start working, even though we didn't import the primitive module which includes a binding for + (ie, scheme).

This is due to the (sometimes?) different treatment of ##core#aliased and ##core#primitive.

comment:4 Changed 7 years ago by sjamaan

Looks like the first order of business should be to try and eliminate the special handling of primitives.

comment:5 Changed 5 years ago by sjamaan


We're not going to fix this in the CHICKEN 4 branch, but hopefully in the 5 cycle we'll be able to eventually fix it. I'll assign 5.0 as a milestone even though I'm doubtful we'll make it as soon as that.

comment:6 Changed 4 years ago by sjamaan

Estimated difficulty: insane

This is the kind of thing that has to die a death by a thousand cuts. That will make it seem "easy", but it will take a long time before we have everything covered.

comment:7 Changed 4 years ago by sjamaan

Milestone: 5.05.1

Still needs to die, but we won't manage to do that before 5.0

comment:8 Changed 3 years ago by sjamaan

Another catch, from #1441:

(module undef (undefined)
  (import scheme)
  (define undefined 1))

(module expando (do-it)
  (import scheme)
  (define-syntax do-it
    (syntax-rules ()
       (let-syntax ((final
                     (syntax-rules ()
                       ((_ ?x) ?x))))
         (final undefined))))))

(import undef expando)
;; Should fail, not print 1, because the let-syntax expansion should rename introduced 
;; identifiers from its SE (but input should be looked up here)
(print (do-it))

comment:9 Changed 22 months ago by sjamaan

Milestone: 5.15.2

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

comment:10 Changed 17 months ago by felix winkelmann

Milestone: 5.25.3
Priority: criticalmajor
Note: See TracTickets for help on using tickets.