From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#25861: 25.1.91; error from js-mode indentation function Date: Fri, 24 Feb 2017 08:08:21 -0700 Message-ID: <871sunwrru.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1487949079 6474 195.159.176.226 (24 Feb 2017 15:11:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 24 Feb 2017 15:11:19 +0000 (UTC) To: 25861@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 24 16:11:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chHWa-00010l-Jw for geb-bug-gnu-emacs@m.gmane.org; Fri, 24 Feb 2017 16:11:13 +0100 Original-Received: from localhost ([::1]:38022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chHWg-0001G6-Cy for geb-bug-gnu-emacs@m.gmane.org; Fri, 24 Feb 2017 10:11:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chHWV-0001DA-Rx for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:11:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chHWQ-0000S7-H6 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:11:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chHWQ-0000S0-Aa for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1chHWQ-0004ra-5U for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Feb 2017 15:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25861 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148794900318602 (code B ref -1); Fri, 24 Feb 2017 15:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Feb 2017 15:10:03 +0000 Original-Received: from localhost ([127.0.0.1]:54813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chHVR-0004pm-L2 for submit@debbugs.gnu.org; Fri, 24 Feb 2017 10:10:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chHVP-0004pQ-Pq for submit@debbugs.gnu.org; Fri, 24 Feb 2017 10:10:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chHVI-0008TH-TG for submit@debbugs.gnu.org; Fri, 24 Feb 2017 10:09:54 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:41015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1chHVI-0008TD-PW for submit@debbugs.gnu.org; Fri, 24 Feb 2017 10:09:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chHVG-0000av-T3 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:09:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chHVA-0008Qe-66 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:09:50 -0500 Original-Received: from gproxy9-pub.mail.unifiedlayer.com ([69.89.20.122]:52925 helo=gproxy9.mail.unifiedlayer.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1chHV9-0008Q0-IS for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2017 10:09:44 -0500 Original-Received: from CMOut01 (unknown [10.0.90.82]) by gproxy9.mail.unifiedlayer.com (Postfix) with ESMTP id 9EACB1E0CD4 for ; Fri, 24 Feb 2017 08:09:35 -0700 (MST) Original-Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id of8P1u01T2f2jeq01f8SAW; Fri, 24 Feb 2017 08:08:37 -0700 X-Authority-Analysis: v=2.1 cv=U+QBU4bu c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=n2v9WMKugxEA:10 a=_aJvCrrlTHCNgT2sBvoA:9 a=zstS-IiYAAAA:8 a=ovv75l2_ioIVEEnID7MA:9 a=NaBNEV6Y9MUdQ3FXzMEA:9 a=3s5XkB_WncXHi8Yv:21 a=4m-WG22h1SBT4RC0:21 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=X4yNRkt2LVmSktZd2HrbaMC5cVUXwHhPDhoh4oSf7L8=; b=tFrP2CSdOELy7aidDWQpXo6wkx Hl0dEo71tQnLzfLFpmXvu+k5sZdcNqLV5/a8nd/C6UI3NQvNhry1RJt4fQqLq4XEi6syX17+raLr4 UfW7as8YidiMBzJDE/qtv2Fpo; Original-Received: from 174-16-128-54.hlrn.qwest.net ([174.16.128.54]:37182 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1chHTr-0008Qw-IY; Fri, 24 Feb 2017 08:08:23 -0700 X-Attribution: Tom X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.128.54 X-Exim-ID: 1chHTr-0008Qw-IY X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-128-54.hlrn.qwest.net (bapiya) [174.16.128.54]:37182 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129738 Archived-At: --=-=-= Content-Type: text/plain I sent this report last night but it didn't go through, so I'm re-sending. While working on some JS code I noticed that when writing a certain file, I got a "scan-error" when I typed TAB. I tracked this down to a buglet in js--indent-in-array-comp. This patch fixes the problem by wrapping the call to forward-sexp there in a condition-case. I've added a new test case as well. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: the patch commit e8a35066ea4d30286836b2510e5c58409784fb97 Author: Tom Tromey Date: Fri Feb 24 00:24:17 2017 -0700 Fix indentation error in js.el * lisp/progmodes/js.el (js--indent-in-array-comp): Wrap forward-sexp call in condition-case. * test/lisp/progmodes/js-tests.el (js-mode-indentation-error): New test. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 6e313dc..65325a8 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1986,11 +1986,16 @@ js--indent-in-array-comp (js--forward-syntactic-ws) (if (looking-at "[[{]") (let (forward-sexp-function) ; Use Lisp version. - (forward-sexp) ; Skip destructuring form. - (js--forward-syntactic-ws) - (if (and (/= (char-after) ?,) ; Regular array. - (looking-at "for")) - (match-beginning 0))) + (condition-case nil + (progn + (forward-sexp) ; Skip destructuring form. + (js--forward-syntactic-ws) + (if (and (/= (char-after) ?,) ; Regular array. + (looking-at "for")) + (match-beginning 0))) + (scan-error + ;; Nothing to do here. + nil))) ;; To skip arbitrary expressions we need the parser, ;; so we'll just guess at it. (if (and (> end (point)) ; Not empty literal. diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 99f5898..07e659a 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el @@ -118,6 +118,16 @@ ;; implementation not recognizing the comment example. (should-not (syntax-ppss-context (syntax-ppss)))))) +(ert-deftest js-mode-indentation-error () + (with-temp-buffer + (js-mode) + ;; The bug previously was that requesting re-indentation on the + ;; "{" line here threw an exception. + (insert "const TESTS = [\n{") + (js-indent-line) + ;; Any success is ok here. + (should t))) + (provide 'js-tests) ;;; js-tests.el ends here --=-=-= Content-Type: text/plain Tom In GNU Emacs 25.1.91.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.7) of 2017-02-02 built on bapiya Repository revision: 7e02a477bbcabb4e65aeecade79b67357c0b9dae Windowing system distributor 'Fedora Project', version 11.0.11901000 System Description: Fedora release 25 (Twenty Five) Configured using: 'configure --prefix=/home/tromey/Emacs/install/ --with-modules' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES Important settings: value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Diff Minor modes in effect: vc-parent-buffer: *vc-change-log* whitespace-mode: t shell-dirtrack-mode: t diff-auto-refine-mode: t which-function-mode: t erc-services-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-match-mode: t erc-netsplit-mode: t erc-hl-nicks-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t savehist-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent messages: No new newsgroups Checking new news... Reading active file from archive via nnfolder...done Reading active file via nndraft...done Checking new news...done nnimap read 0k from mail.tromey.com Discard changes to this group and exit? (y or n) y nnimap read 0k from mail.tromey.com Mark set Mark saved where search started Load-path shadows: /home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-gnu hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-gnu /home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs /home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-pkg hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-pkg /home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-autoloads hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-autoloads /home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-org hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-org /home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/play/bubbles /home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-inspect hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/net/soap-inspect /home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-client hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/net/soap-client Features: (cmake-mode pcmpl-unix pcmpl-gnu autoconf autoconf-mode tramp-cache markdown-mode ffap dired-aux nndoc gnus-dup debbugs-gnu debbugs soap-client rng-xsd rng-dt rng-util xsd-regexp autoload tar-mode cus-edit highlight-refontification tabify man shadow emacsbug conf-mode two-column iso-transl perl-mode sh-script executable cal-move nnregistry python tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize make-mode etags cursor-sensor mhtml-mode org-bullets org-element org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view image-mode org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs org-loaddefs gnus-fun gnus-draft noutline outline ido skeleton css-mode smie eww url-queue trace find-dired descr-text gdb-shell lisp-mnt url-handlers url-http url-gw url-auth lex edebug debug m4-mode bbdb-sc supercite regi xref project log-edit js json map sgml-mode flow-fill gnus-html xml url-cache mm-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf eieio-opt speedbar sb-image ezimage dframe find-func whitespace tcl log-view pcvs-util vc-annotate term/xterm xterm smerge-mode goto-addr shell find-file idutils derived bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds jka-compr mailalias mail-hist nnir sort gnus-cite smiley shr-color url-util url-parse url-vars shr dom subr-x browse-url mm-archive gnus-async gnus-bcklg qp gnus-ml disp-table gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua bbdb-com crm network-stream nsm starttls gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache gnus-registry registry eieio-compat eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo smtpmail gnus-start gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range gnus-win gnus gnus-ems nnheader bbdb-message sendmail mail-extr message idna dired rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils mailheader gud dwarf-mode copyright dabbrev misearch multi-isearch vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs add-log rx vc-git diff-mode easy-mmode rust-mode flyspell ispell diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs which-func imenu minimap autorevert filenotify cus-start cus-load status erc-services erc-list erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend erc-compat format-spec auth-source eieio gnus-util mm-util help-fns mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb bbdb-site timezone ange-ftp comint ansi-color ring server savehist finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl weblogger-autoloads info package epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 3556231 522013) (symbols 48 150328 85) (miscs 40 38402 18800) (strings 32 619121 202100) (string-bytes 1 19260218) (vectors 16 140379) (vector-slots 8 3021761 102883) (floats 8 3865 1696) (intervals 56 474632 9016) (buffers 976 551)) --=-=-=--