I have a fix for this by pushing the method idiom to another module. So it is not a burning issue.
Strange that I did not dee this error before in the 2.x series ever. Isn't it so that for procedures define in a (let () ...) the case you are mentioning happened before but I was on the impression that no inlining was done for defines on different places in the module before I also have a request to be able to silence warning of unbound variables that is not so for e.g. a python implementation. Previously I modded message.scm and compile.scm so that I can add symbols that will not issue a warning when compiling. It consists of (define %dont-warn-list (make-fluid '())) ;; Exported (define %add-to-warn-list (lambda (sym) (fluid-set! (M %dont-warn-list) (cons sym (fluid-ref (M %dont-warn-list)))))) And inside the warning emitter one checks for matches in the don't warn list and mute if it matches. For this to work we need also change the compiler as in compile.scm (see the %dont-warn-list line ... (define-set-C compile-file (lambda* (file #:key (output-file #f) (from ((C default-language) file)) (to 'bytecode) (env ((C default-environment) from)) (opts '()) (canonicalization 'relative)) (with-fluids (((C %in-compile ) #t ) ((C %in-file ) file ) ((@@ (system base message) %dont-warn-list) '() ) ((C %file-port-name-canonicalization) canonicalization ) ((C %current-file% ) file)) It would also be fabulous to direct the compiler depeneding on extensions of the file which is also something I have to make the python environment nicer. On Tue, Jan 14, 2020 at 10:17 PM Andy Wingo <wi...@pobox.com> wrote: > On Tue 14 Jan 2020 21:13, Stefan Israelsson Tampe <stefan.ita...@gmail.com> > writes: > > > Okey, here is another case that fails with the patch that prevents > identity misses for toplevels e.g we need similar fixes for anonymous > functions. > > > > (define-module (b) > > #:export (q)) > > > > (define h (make-hash-table)) > > (define (method f) > > (hash-set! h f 1) > > f) > > (define q (method (lambda x x))) > > > > (pk (hash-ref h q)) > > > > This fails with (#f) > > > > I solved this in my code by placing the method function in another > module. > > Interestingly, this case is not really related to the declarative > bindings optimization, letrectification, or other things. It's the same > as: > > (let ((h (make-hash-table))) > (define (method f) > (hash-set! h f 1) > f) > (let* ((q (let ((f (lambda x x))) > (method f)))) > (pk (hash-ref h q)))) > > I.e. no top-level bindings are needed. This prints #f in releases as > old as 2.0.14 and probably older :) It optimizes as: > > (let* ((h (make-hash-table)) > (q (begin > (hash-set! h (lambda x x) 1) > (lambda x x)))) > (pk (hash-ref h q))) > > So, not a recent change. Of course we can discuss whether it's the > right thing or not! > > Andy >