#286 swank::parse-package mistranslation

Unstable_git-CVS
closed
nobody
None
1
2014-09-23
2014-02-28
Anonymous
No

swank::parse-package is mistranslated.

Input:

(defun parse-package (string)
  "Find the package named STRING.
   Return the package or nil."
  ;; STRING comes usually from a (in-package STRING) form.
  (ignore-errors
    (find-package (let ((*package* *swank-io-package*))
                    (read-from-string string)))))

The content of the ignore-errors form looks like this:

{
  cl_fixnum v2;
  ecl_bds_bind(cl_env_copy,ECL_SYM("*PACKAGE*",43),ecl_symbol_value(VV[89])); /*  *PACKAGE* */
  {
    v2 = ecl_fixnum(cl_read_from_string(1, v1string));
    ecl_bds_unwind1(cl_env_copy);
  }
  value0 = cl_find_package(ecl_make_fixnum(v2));

So ECL seems to think that read-from-string will only return a fixnum ... instead of a symbol or string. I guess the second value is mistaken to be the first.

1 Attachments

Discussion

  • P.Marek
    P.Marek
    2014-02-28

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -22,4 +22,4 @@
           }
           value0 = cl_find_package(ecl_make_fixnum(v2));
    
    -So ECL seems to think that read-from-string will only return a fixnum ... instead of a symbol or string.
    +So ECL seems to think that read-from-string will only return a fixnum ... instead of a symbol or string. I guess the second value is mistaken to be the first.
    
     

  • Anonymous
    2014-02-28

    (proclamation read-from-string (string &optional gen-bool t &key)
    (values t ext:array-index))

    It would be interesting to know if this can occur for other functions
    proclaimed to return (VALUES T ...) in cmp/cmp/proclamations.lsp

     
  • P.Marek
    P.Marek
    2014-02-28

    gives this C output.

    And this output:

    ;;;
    ;;; Compiling .../swank-guess-package.lisp.
    ;;; OPTIMIZE levels: Safety=3, Space=0, Speed=0, Debug=3
    ;;;
    ;;; Compiling (DEFUN PARSE-PACKAGE ...).
    ;;; End of Pass 1.
    ;;; Style warning:
    ;;;   in file swank-guess-package.lisp, position 82
    ;;;   at (DEFUN PARSE-PACKAGE ...)
    ;;;   ! The argument 1 of function FIND-PACKAGE has type
    ;;; ARRAY-INDEX
    ;;; instead of expected
    ;;; PACKAGE-DESIGNATOR
    ;;; Emitting code for PARSE-PACKAGE.
    ;;; Emitting code for #:G3.
    ;;; Finished compiling ...
    
     
    Attachments
  • P.Marek
    P.Marek
    2014-02-28

    tracing of PROPAGATE-TYPES says

    1> (C::PROPAGATE-TYPES SI:SELECT-PACKAGE (#<form LOCATION 2BDD210>))
    <1 (C::PROPAGATE-TYPES PACKAGE)
    1> (C::PROPAGATE-TYPES MAPC (#<form LOCATION 20AC030> #<form LOCATION 20C6E70>))
    <1 (C::PROPAGATE-TYPES C::PROPER-LIST)
    ;;; Compiling (DEFUN PARSE-PACKAGE ...).
    1> (C::PROPAGATE-TYPES CONS (#<form LOCATION 213A930> #<form LOCALS 213A4E0>))
    <1 (C::PROPAGATE-TYPES CONS)
    1> (C::PROPAGATE-TYPES LIST (#<form CALL-GLOBAL 2177480>))
    <1 (C::PROPAGATE-TYPES LIST)
    1> (C::PROPAGATE-TYPES CONS (#<form CALL-GLOBAL 21D8BD0> #<form VAR 21D8A50>))
    <1 (C::PROPAGATE-TYPES CONS)
    1> (C::PROPAGATE-TYPES READ-FROM-STRING (#<form VAR 21F0BA0>))
    <1 (C::PROPAGATE-TYPES (VALUES T EXT:ARRAY-INDEX))
    1> (C::PROPAGATE-TYPES FIND-PACKAGE (#<form LET* 220AFC0>))
    <1 (C::PROPAGATE-TYPES (OR PACKAGE NULL))
    1> (C::PROPAGATE-TYPES SI::SET-DOCUMENTATION (#<form LOCATION 2253AB0> #<form LOCATION 2253450> #<form LOCATION 2253120>))
    <1 (C::PROPAGATE-TYPES (VALUES &REST T))
    ;;; End of Pass 1.
    1> (C::PROPAGATE-TYPES SI:SELECT-PACKAGE (#<form LOCATION 2BDD210>))
    <1 (C::PROPAGATE-TYPES PACKAGE)
    1> (C::PROPAGATE-TYPES MAPC (#<form LOCATION 20AC030> #<form LOCATION 20C6E70>))
    <1 (C::PROPAGATE-TYPES C::PROPER-LIST)
    1> (C::PROPAGATE-TYPES READ-FROM-STRING (#<form VAR 21F0BA0>))
    <1 (C::PROPAGATE-TYPES (VALUES T EXT:ARRAY-INDEX))
    1> (C::PROPAGATE-TYPES FIND-PACKAGE (#<form LET* 220AFC0>))
    
     
  • P.Marek
    P.Marek
    2014-02-28

    A slight change makes compilation work: from

    (find-package 
      (let ((*package* *swank-io-package*))
        (read-from-string string)))))
    

    to

    (let ((*package* *swank-io-package*))
      (find-package 
        (read-from-string string)))))
    

    is enough.

     
  • P.Marek
    P.Marek
    2014-03-02

    Hmmm, even for the previous (LET (FIND-PACKAGE (READ-FROM-STRING))) version I get the warning:

    ;;; Style warning:
    ;;;   in file swank-guess-package.lisp, position 658
    ;;;   at (DEFUN PARSE-PACKAGE-OK ...)
    ;;;   ! The argument 1 of function FIND-PACKAGE has type
    ;;; ARRAY-INDEX
    ;;; instead of expected
    ;;; PACKAGE-DESIGNATOR
    
     

  • Anonymous
    2014-03-03

    http://sourceforge.net/p/ecls/ecl/ci/7262dd7b0e4113fd5b7deefd121020a96760dd5d/

    swank-io-package doesn't seem to be bound (not exported by the SWANK
    package, and tests might run without slime/swank). Can this be a problem
    if running tests?

    Also, I don't seem to be able to reproduce code assuming a fixnum with those,
    when using a local build from around Nov 30 (custom repository, last merged
    from master ECL repository at Tue Oct 29 20:53:37 2013 -0400.

    Attaching files didn't work, so:

    (declaim (optimize (speed 3) (safety 0) (debug 0)))

    ;; XXX Doesn't exist if swank/slime not running, which it is not for this test
    (defparameter swank-io-package (find-package "CL-USER"))

    (defun test1 ()
    (assert
    (let ((string ":cl-user"))
    (find-package
    (let ((package swank-io-package))
    (read-from-string string))))))

    (defun test2 ()
    (assert
    (let ((string ":cl-user"))
    (let ((package swank-io-package))
    (find-package
    (read-from-string string))))))

    / function definition for TEST1 /
    / optimize speed 3, debug 0, space 0, safety 0 /
    static cl_object L1test1()
    {
    cl_object T0;
    const cl_env_ptr cl_env_copy = ecl_process_env();
    cl_object value0;
    TTL:
    goto L2;
    L1:;
    si_assert_failure(1, VV[1]);
    L2:;
    ecl_bds_bind(cl_env_copy, ECL_SYM("PACKAGE", 43), ECL_SYM_VAL(cl_env_copy, VV[0])); / PACKAGE /
    T0 = cl_read_from_string(1, VV[2]);
    ecl_bds_unwind1(cl_env_copy);
    if ((cl_find_package(T0)) != ECL_NIL) {
    goto L5;
    }
    goto L1;
    L5:;
    value0 = ECL_NIL;
    cl_env_copy->nvalues = 1;
    return value0;
    }

    / function definition for TEST2 /
    / optimize speed 3, debug 0, space 0, safety 0 /
    static cl_object L2test2()
    {
    cl_object T0;
    const cl_env_ptr cl_env_copy = ecl_process_env();
    cl_object value0;
    TTL:
    goto L2;
    L1:;
    si_assert_failure(1, VV[4]);
    L2:;
    ecl_bds_bind(cl_env_copy, ECL_SYM("PACKAGE", 43), ECL_SYM_VAL(cl_env_copy, VV[0])); / PACKAGE /
    T0 = cl_read_from_string(1, VV[2]);
    if ((cl_find_package(T0)) != ECL_NIL) {
    ecl_bds_unwind1(cl_env_copy);
    goto L5;
    }
    ecl_bds_unwind1(cl_env_copy);
    goto L1;
    L5:;
    value0 = ECL_NIL;
    cl_env_copy->nvalues = 1;
    return value0;
    }

     
  • P.Marek
    P.Marek
    2014-03-03

    Yes, *swank-io-package* unbound is bad for tests; I changed it there to (FIND-PACKAGE :cl) now.

    But for the problem itself it doesn't matter - if the code is run, there's a type error in CL:STRING because the cl_object passed in is a FIXNUM (which it actually shouldn't be).

    I'm now compiling

    237af2e803a2bf9d1044875ed9b7d7b301cad343
    

    to see whether it's a recent problem...

    BTW, my generated C file says

    optimize speed 0, debug 3, space 0, safety 3
    

    so the optimizer settings might not matter.

     
  • P.Marek
    P.Marek
    2014-03-03

    Yeah, I get that with the old version, too.

     
  • P.Marek
    P.Marek
    2014-03-08

    Seems to be fixed by Stas' "Fix VALUES declaration processing.", 3f0ce7f7d40a2d2a8eed77e9fc5b588922c335b5.

     


Anonymous


Cancel   Add attachments