GNU bug report logs - #16416
24.3; [SMIE] Assertion failure in smie-prec2->grammar

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: cauderlier@HIDDEN (Raphaël Cauderlier); dated Sat, 11 Jan 2014 19:56:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 16416 <at> debbugs.gnu.org:


Received: (at 16416) by debbugs.gnu.org; 14 Jan 2014 10:03:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 14 05:03:37 2014
Received: from localhost ([127.0.0.1]:49738 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1W30qO-0007aw-OD
	for submit <at> debbugs.gnu.org; Tue, 14 Jan 2014 05:03:37 -0500
Received: from redisdead.crans.org ([138.231.136.39]:56412)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <cauderlier@HIDDEN>) id 1W30qM-0007ah-DR
 for 16416 <at> debbugs.gnu.org; Tue, 14 Jan 2014 05:03:35 -0500
Received: from zamok.crans.org.crans.org (zamok.crans.org
 [IPv6:2a01:240:fe3d:4:219:bbff:fe3c:4f76])
 by redisdead.crans.org (Postfix) with ESMTP id 0834A2416;
 Tue, 14 Jan 2014 11:03:32 +0100 (CET)
From: Raphael Cauderlier <cauderlier@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#16416: 24.3; [SMIE] Assertion failure in smie-prec2->grammar
References: <87y52mo11v.fsf@HIDDEN>
 <jwvha97qt3u.fsf-monnier+emacsbugs@HIDDEN>
Date: Tue, 14 Jan 2014 11:03:32 +0100
In-Reply-To: <jwvha97qt3u.fsf-monnier+emacsbugs@HIDDEN> (Stefan Monnier's
 message of "Mon, 13 Jan 2014 20:04:07 -0500")
Message-ID: <vt2lhyi3mob.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.1 (/)
X-Debbugs-Envelope-To: 16416
Cc: 16416 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Stefan Monnier <monnier@HIDDEN> writes:

>> (smie-prec2->grammar (smie-bnf->prec2 '((name) (l ("a" name)))))
>> This raised the following error message:
>> (cl-assertion-failed (numberp (car cons)))
>
> Hmm..indeed.  The assertion can be removed, but then we bump into
> another signal.  The problem is that the grammar is simply "too
> trivial" and smie.el seems to bump into invalid assumptions in
> that case.  As soon as you add some other terminal to the "l" rule, or
> the "name" rule, or you use "l" somewhere, the problem disappears.
>
> Intuitively this problem might manifest itself in a more realistic
> grammar,

I don't know if you would call it realistic but I actually got it with
the following grammar:

  (smie-prec2->grammar
   (smie-bnf->prec2
    '((id)
      (prelude ("#NAME" id))
      (line ("#IMPORT" id)
            (term ".")
            (term ":=3D" term ".")
            (rule)
            (rule ".")
            ("#ASSERT" term "=3D~" term "."))
      (rule ("[" context "]" term "-->" term))
      (decl (id ":" term))
      (context (decl "," context)
               (decl))
      (term (id)
            ("{" id "}")
            (decl)
            ("_")
            (term "->" term)
            (decl "=3D>" term)))
    '((assoc ":")
      (assoc "->" "=3D>"))))

which I find a bit more complicated than the example grammar given in
the manual section `SMIE Grammar'.

I wrote this from Dedukti BNF grammar.  Dedukti
(https://www.rocq.inria.fr/deducteam/Dedukti/index.html) is a simple
language for which I am writing a major mode
(https://github.com/rafoo/dedukti-mode/blob/master/dedukti-mode.el).

I then minimized the example before reporting, keeping only the `id'
empty rule and the first `line' rule.

> As soon as you add some other terminal to the "l" rule, or
> the "name" rule, or you use "l" somewhere, the problem disappears.

Thank you for your suggestion, I added "\n" at the end of, the first
`line' rule and the problem is solved for me; I can continue to play
with SMIE :)

> yet I don't quite see in which case, and for that reason
> I don't really see yet what would be the right fix.  I'm tempted to
> think that the problem is partly to blame on smie-bnf->prec2 which
> generates a prec2 table where "a" is missing (except for the side info
> of :smie-open/close-alist).

Thank you for your investigation and thank you for SMIE; I am sure it
will help me a lot improving my major mode indentation!

--=20
Rapha=C3=ABl Cauderlier




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16416; Package emacs. Full text available.

Message received at 16416 <at> debbugs.gnu.org:


Received: (at 16416) by debbugs.gnu.org; 14 Jan 2014 01:04:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 13 20:04:10 2014
Received: from localhost ([127.0.0.1]:49545 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1W2sQM-0008Kl-Ek
	for submit <at> debbugs.gnu.org; Mon, 13 Jan 2014 20:04:10 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.181]:10548)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1W2sQK-0008Kc-HV
 for 16416 <at> debbugs.gnu.org; Mon, 13 Jan 2014 20:04:08 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCoyj/2dsb2JhbABEvw4Xc4IfAQUnLyMQCzQSFBgNiEjBLZEKA4hhnBmBXoMV
X-IPAS-Result: Av4EABK/CFFMCoyj/2dsb2JhbABEvw4Xc4IfAQUnLyMQCzQSFBgNiEjBLZEKA4hhnBmBXoMV
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="44869543"
Received: from 76-10-140-163.dsl.teksavvy.com (HELO pastel.home)
 ([76.10.140.163])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 13 Jan 2014 20:04:07 -0500
Received: by pastel.home (Postfix, from userid 20848)
 id C8A246105F; Mon, 13 Jan 2014 20:04:07 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: cauderlier@HIDDEN (=?windows-1252?Q?Rapha=EBl?= Cauderlier)
Subject: Re: bug#16416: 24.3; [SMIE] Assertion failure in smie-prec2->grammar
Message-ID: <jwvha97qt3u.fsf-monnier+emacsbugs@HIDDEN>
References: <87y52mo11v.fsf@HIDDEN>
Date: Mon, 13 Jan 2014 20:04:07 -0500
In-Reply-To: <87y52mo11v.fsf@HIDDEN> (=?windows-1252?Q?=22Rapha?=
 =?windows-1252?Q?=EBl?= Cauderlier"'s message
 of "Sat, 11 Jan 2014 18:55:56 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 16416
Cc: 16416 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> (smie-prec2->grammar (smie-bnf->prec2 '((name) (l ("a" name)))))
> This raised the following error message:
> (cl-assertion-failed (numberp (car cons)))

Hmm..indeed.  The assertion can be removed, but then we bump into
another signal.  The problem is that the grammar is simply "too
trivial" and smie.el seems to bump into invalid assumptions in
that case.  As soon as you add some other terminal to the "l" rule, or
the "name" rule, or you use "l" somewhere, the problem disappears.

Intuitively this problem might manifest itself in a more realistic
grammar, yet I don't quite see in which case, and for that reason
I don't really see yet what would be the right fix.  I'm tempted to
think that the problem is partly to blame on smie-bnf->prec2 which
generates a prec2 table where "a" is missing (except for the side info
of :smie-open/close-alist).


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16416; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Jan 2014 19:55:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 11 14:55:47 2014
Received: from localhost ([127.0.0.1]:47074 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1W24el-0005k8-4z
	for submit <at> debbugs.gnu.org; Sat, 11 Jan 2014 14:55:47 -0500
Received: from eggs.gnu.org ([208.118.235.92]:51866)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <cauderlier@HIDDEN>) id 1W22vC-0002iY-QE
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2014 13:04:35 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <cauderlier@HIDDEN>) id 1W22v6-0005dB-Iq
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2014 13:04:34 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:59304)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <cauderlier@HIDDEN>) id 1W22v6-0005d1-G2
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2014 13:04:28 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53471)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <cauderlier@HIDDEN>) id 1W22v0-00027o-UG
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2014 13:04:28 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <cauderlier@HIDDEN>) id 1W22uu-0005Zm-5Z
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2014 13:04:22 -0500
Received: from redisdead.crans.org ([138.231.136.39]:57193)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <cauderlier@HIDDEN>) id 1W22ut-0005ZQ-Q2
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2014 13:04:16 -0500
Received: from mojito.crans.org (unknown
 [IPv6:2a01:e34:ec1d:27d0:864b:f5ff:feb8:9b78])
 (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits))
 (No client certificate requested)
 by redisdead.crans.org (Postfix) with ESMTPSA id 874F32557
 for <bug-gnu-emacs@HIDDEN>; Sat, 11 Jan 2014 18:56:36 +0100 (CET)
From: cauderlier@HIDDEN (=?utf-8?Q?Rapha=C3=ABl?= Cauderlier)
To: bug-gnu-emacs@HIDDEN
Subject: 24.3; [SMIE] Assertion failure in smie-prec2->grammar
Date: Sat, 11 Jan 2014 18:55:56 +0100
Message-ID: <87y52mo11v.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 11 Jan 2014 14:55:40 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)


Hello,

I started emacs with emacs -Q and evaled the following file with
load-file:

-----
(require 'smie)
(smie-prec2->grammar (smie-bnf->prec2 '((name) (l ("a" name)))))
-----

This raised the following error message:

(cl-assertion-failed (numberp (car cons)))

where I expected a SMIE grammar to be returned without error message.
The inner function smie-bnf->prec2 doesn't fail and the documentation
string for the outter function smie-prec2->grammar indicates that it's
argument could be a value returned by smie-bnf->prec2:

-----
smie-prec2->grammar is a compiled Lisp function in `smie.el'.

(smie-prec2->grammar PREC2)

Take a 2D precedence table and turn it into an alist of precedence levels.
PREC2 is a table as returned by `smie-precs->prec2' or
`smie-bnf->prec2'.
-----

I hope I gave you enough information to reproduce this issue.  I'm not
very familiar with the Lisp Debugger so I don't know how to get a
backtrace from a cl-assertion-failed.

Have a nice day!

--=20
Rapha=C3=ABl Cauderlier



In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.6)
 of 2013-12-22 on brahms, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description:	Debian GNU/Linux testing (jessie)

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=3D/usr' '--sharedstatedir=3D/var/lib' '--libexecdir=3D/usr/lib'
 '--localstatedir=3D/var/lib' '--infodir=3D/usr/share/info'
 '--mandir=3D/usr/share/man' '--with-pop=3Dyes'
 '--enable-locallisppath=3D/etc/emacs24:/etc/emacs:/usr/local/share/emacs/2=
4.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-l=
isp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=3D/usr/lib/x86_64-linux-gnu' '--with-x=3Dyes'
 '--with-x-toolkit=3Dgtk3' '--with-toolkit-scroll-bars'
 'build_alias=3Dx86_64-linux-gnu' 'CFLAGS=3D-g -O2 -fstack-protector
 --param=3Dssp-buffer-size=3D4 -Wformat -Werror=3Dformat-security -Wall'
 'LDFLAGS=3D-Wl,-z,relro' 'CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2''

Important settings:
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x l o a d - f i l e <return> s m i e - b u g . l=20
<backspace> e l <return> M-x r e p o r t - e m a c=20
s - b u g <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading /home/harry/test/smie-bug.el (source)...
smie-prec2->grammar: Assertion failed: (numberp (car cons))

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils smie time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)




Acknowledgement sent to cauderlier@HIDDEN (Raphaël Cauderlier):
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#16416; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.