Bug 3689

Summary: #f check is not done by nth
Product: UIM Reporter: TOKUNAGA Hiroyuki <tkng>
Component: generic Scheme codesAssignee: uim-bugs
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: high    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description TOKUNAGA Hiroyuki 2005-07-03 03:41:55 UTC
In revision 922, I commited #f check for getter of define-record. It was reverted in
revison 929, but IMHO this is need.

As an example, exec following code. With revision 922, "end e" would not be printed.

== start of a.scm ================================
(require "im.scm")

(define (a)
  (print "start a")
  (print (im-lang #f))
  (print "end e"))

(a)
== end of a.scm =================================
Comment 1 YamaKen 2005-07-03 04:29:46 UTC
uim> (a)
"start a"
ERROR: bad arg to nth (see errobj)

r929 results as above. The message "ERROR: bad arg to nth" and subsequent
termination of execution is the error check what I mensioned in the commit
message of r929. Continuation without such termination as performed in r922 does
not make sense. What we should do is removing (im-lang #f) condition.
Comment 2 TOKUNAGA Hiroyuki 2005-07-03 05:16:00 UTC
IMHO following code should generate following result.

"start a"
"FAILED"
"end e"

But revision 929 doesn't. It's not comfortable for me.

== start of a2.scm ====================================
(require "im.scm")

(define (a)
  (print "start a")
  (if (im-lang #f)
      (print "OK")
      (print "FAILED"))
  (print "end e"))

(a)

== end of a2.scm ======================================
Comment 3 YamaKen 2005-07-03 05:38:15 UTC
im-lang expects an im record as argument. So (im-lang #f) is completely invalid
form. Suppose ((im *)NULL)->lang in C.

I can't imagine when (im-lang #f) will happen. Please show me actual example.
Comment 4 TOKUNAGA Hiroyuki 2005-07-05 04:38:51 UTC
As an actual example, exec current uim-module-manager. (Note, you should make back
up of your loader.scm and installed-module.scm at first, it's not work fine at
this point.)

It works with util.scm rev922, but doesn't with 929. I don't want to debug,
because I don't 
have enough time and morale.
Comment 5 YamaKen 2005-07-05 05:14:48 UTC
I decline the change since your code of r922 has a design error. See following
example.

(define-record 'foo
  '((initialized? #f)))
(define rec (foo-new))

(foo-initialized? rec)  ==> #f
(foo-initialized? #f)   ==> #f

The two results can't be distinguished by its caller. Although latter form
outputs error message for human, the caller code can't detect it.

To avoid this ambiguity, explicit #f check preceding foo-initialized? is
required as follows.

(if rec
    (foo-initialized? rec)
    (error-handlings))

I decline the design error and you should repair your own code as above. I'll
debug my codes when you found something wrong other than yours.
Comment 6 YamaKen 2006-06-09 01:12:50 UTC
This problem is already fixed by the rewrite around uim-module-manager.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.