GNU bug report logs - #77369
typescript-ts-mode's defun definition is wrong

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: Daniel Colascione <dancol@HIDDEN>; Done: Yuan Fu <casouri@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 77369) by debbugs.gnu.org; 3 Apr 2025 07:30:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 03 03:30:32 2025
Received: from localhost ([127.0.0.1]:60739 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u0F20-0006rw-K7
	for submit <at> debbugs.gnu.org; Thu, 03 Apr 2025 03:30:32 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:60530)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u0F1w-0006rc-LE
 for 77369 <at> debbugs.gnu.org; Thu, 03 Apr 2025 03:30:29 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1u0F1p-00024V-Ok; Thu, 03 Apr 2025 03:30:21 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=oxpH2eQfvYRDv+7OhOO0hgpznH41qBcNFzpStLo6ZD4=; b=cSM9ySG0wNJJ
 JXbS2JJhkcJlV4g9FVnbM9Ais17/2frbj+v4pR8j9g2pL9XRQDkSkd/7JG6Ud++wjyWr4f2lxSus3
 lHDPNXv/a3YsPJjVEfFQvLB8wfBA8TWcHbCPrzztdAtcdBUdHos49/i2zOP5hhOKKsfIr8YSqwAo7
 1VS28PoIaiVTXfq8oDw/Mp47YmnTZ4Ct6jBkruIcf8Bw0JIfdPSgThTV9HE82TU3pd4HZG6RtSyaz
 2DrM/KZPRlGUHkyv5rWmcPKB77n5Uthy3dLsXi3pF6iVSHR1D+X4Rx5EJbBrZMZ05V0usB1JL5UMK
 wP2kSPoV0wUcc79pTkm3VA==;
Date: Thu, 03 Apr 2025 10:30:19 +0300
Message-Id: <86plhtzoqc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Colascione <dancol@HIDDEN>,
 Yuan Fu <casouri@HIDDEN>, Juri Linkov <juri@HIDDEN>
In-Reply-To: <m1r02fd7mc.fsf@HIDDEN> (message from Daniel Colascione on
 Sat, 29 Mar 2025 14:17:15 -0400)
Subject: Re: bug#77369: typescript-ts-mode's defun definition is wrong
References: <m1r02fd7mc.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77369
Cc: 77369 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://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: <https://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: -3.3 (---)

> From: Daniel Colascione <dancol@HIDDEN>
> Date: Sat, 29 Mar 2025 14:17:15 -0400
> 
> Not sure whether this is a bug or just surprising design, but in this
> code:
> 
>     function Blah(foo) {
>       const foo = 1;
>       const bar = 2;
>     }
> 
> with point on "const foo", I do not expect end-of-defun to go to "const
> bar".  I expect it to go to the closing curly brace.

Juri and Yuan, any comments or suggestions?




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

Message received at 77369-done <at> debbugs.gnu.org:


Received: (at 77369-done) by debbugs.gnu.org; 30 Mar 2025 04:21:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 30 00:21:26 2025
Received: from localhost ([127.0.0.1]:33961 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tykAo-0008Pl-H4
	for submit <at> debbugs.gnu.org; Sun, 30 Mar 2025 00:21:26 -0400
Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:43250)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1tykAl-0008PS-2d
 for 77369-done <at> debbugs.gnu.org; Sun, 30 Mar 2025 00:21:23 -0400
Received: by mail-pj1-x1036.google.com with SMTP id
 98e67ed59e1d1-2ff615a114bso6785155a91.0
 for <77369-done <at> debbugs.gnu.org>; Sat, 29 Mar 2025 21:21:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743308477; x=1743913277; darn=debbugs.gnu.org;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=kzHGMwOJRcJYB7ocwjtJoND/zC5wa0DBt94/v5AQ3oI=;
 b=niIX5Zk7d6upyDi2rShBz4gtqBIwdjbxQnN+HP6MexezKq2blaYq3EEuwbXBKTy467
 haME793pAS6qVpqMZljXQPvzxFfaPqTNquB1PDNxgDXY7btR4ypADR4dDwvMoq5tShUr
 pXwwqbHIhUrAp8Sg0bx+feeiLZWICEdbzI9D5FOJGiQBX7U583+q3SfQ6CrXeYfIMHMt
 d30kfNUzX+NZEaSudN5OUd+2s7ghwMa3grt8MeeqoVTR9m56nboBl4c6edMgodENhGuS
 x2+la9YeiVsHAQCWIyIShIMkSIy8T2Z0oVF5YKTGBHvwWp9a/Yk+KBYN4SpLQGmgWbH0
 zOvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743308477; x=1743913277;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=kzHGMwOJRcJYB7ocwjtJoND/zC5wa0DBt94/v5AQ3oI=;
 b=g3shSIZhjwo/SHh+NqlyaShgjwi2+PXTb883hCbfZ4/BFrX8sBfZsKQQpkrNsM9BvK
 7UwvY9/IM98J6WAOLAXVpjOAWlV6uKubibjJ7Hpw+jGQnAV5Q6WMC3KwJmefuiuPv8Ve
 B3r7PdWHyCUXtv/369YAhJ5Oi4HCKMJlhZPUwd7k6Zkv6L8m9WjlEBFKAZesHJMguT4c
 TdL1MREtHWY5PMdGlCOpBKofzo29YYEBNlXdX8Cw+R8YNxrwMAp92UBPEtdwOaNtpjil
 ZrElM+DEVqcjxr+cziWm80ZWvzq46oGzhlaysFXMxh1bKBEu1/gWVLYaYruloEZL2jMk
 pDhA==
X-Gm-Message-State: AOJu0Yxqu1PfH1vgA1+YP1P7f3HMfK9VTUHXb/ZAx5V5n6uj/2SShCvr
 VO7+9FYUpcWklZezkqaFHKxytjqhNQQi2UvvxeA2CoAMlBP6Q9sU6y3DnA==
X-Gm-Gg: ASbGncvsHKrMOGf8/6E71tQVKvQe+27QwkJBBGMdL+/LZm1pzoegQh4KoMey/haQb0o
 aV4M55HPevxNHy5R42qUiZpB/2C9IZSoPX+I/lvFnakngmwygfB0QTpygJc4XMx3PuIHxxsRpIZ
 V5wyI44+4VCyWLIOfHNAlKx26zQe0xeWm013nRo42M6usaz/cm+8ddyZKwRHZW0UU19Bca6v3NF
 5HWW7nx7DzyO4uWvoWqQtBZmSb/wAyZMJe6+cHWTUC6piODOiU+O4uw55JpiDVkKetQm0oMmlB7
 9xqx8F7us/UaVLJrJUrAqSAC/JVg3VjbleBtsrKLK0uGX/LI8APH7F1of6Epcz2oxyRS
X-Google-Smtp-Source: AGHT+IGg1UXXLEnDuAmpp/K9v3KpM4IsJBeEGgXeik21aMvvK7GpywNKmQf2DlS3Xn0jamWXxYTYHg==
X-Received: by 2002:a17:90b:258c:b0:2fa:6793:e860 with SMTP id
 98e67ed59e1d1-3051c63c952mr14221797a91.0.1743308476930; 
 Sat, 29 Mar 2025 21:21:16 -0700 (PDT)
Received: from smtpclient.apple ([2601:646:8f81:6120:4c87:420d:deb5:690a])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-3039dfd38a6sm6981241a91.10.2025.03.29.21.21.15
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 29 Mar 2025 21:21:16 -0700 (PDT)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\))
Subject: Re: bug#77369: typescript-ts-mode's defun definition is wrong
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <m1r02fd7mc.fsf@HIDDEN>
Date: Sat, 29 Mar 2025 21:21:05 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <75B4CE4F-7F95-483D-AFAB-7FC5E1719DCC@HIDDEN>
References: <m1r02fd7mc.fsf@HIDDEN>
To: Daniel Colascione <dancol@HIDDEN>
X-Mailer: Apple Mail (2.3826.400.131.1.6)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77369-done
Cc: Theodor Thornhill <theo@HIDDEN>, 77369-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://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: <https://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: -1.0 (-)



> On Mar 29, 2025, at 11:17=E2=80=AFAM, Daniel Colascione =
<dancol@HIDDEN> wrote:
>=20
> Not sure whether this is a bug or just surprising design, but in this
> code:
>=20
>    function Blah(foo) {
>      const foo =3D 1;
>      const bar =3D 2;
>    }
>=20
> with point on "const foo", I do not expect end-of-defun to go to =
"const
> bar".  I expect it to go to the closing curly brace.

Yeah, that=E2=80=99s because const foo =3D 1; is a =
=E2=80=9Clexical_declaration=E2=80=9D, which is considered a defunct in =
typescript-ts-mode, because in js you can have arrow functions like

const Blah =3D (foo) =3D> {
  return true;
};

Which is also a =E2=80=9Clexical_declaration=E2=80=9D. I guess we can =
refine the pattern matching to check if it=E2=80=99s an arrow function =
and only then consider it a defun.

I did that, now on latest master, end-of-defun should move to the end of =
the function in your example.

Yuan=




Notification sent to Daniel Colascione <dancol@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Yuan Fu <casouri@HIDDEN>:
You have taken responsibility. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 29 Mar 2025 18:17:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 29 14:17:29 2025
Received: from localhost ([127.0.0.1]:33000 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tyakL-0005t9-4Z
	for submit <at> debbugs.gnu.org; Sat, 29 Mar 2025 14:17:29 -0400
Received: from lists.gnu.org ([2001:470:142::17]:41670)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <dancol@HIDDEN>) id 1tyakH-0005sq-7r
 for submit <at> debbugs.gnu.org; Sat, 29 Mar 2025 14:17:27 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dancol@HIDDEN>) id 1tyakB-0006Fo-HO
 for bug-gnu-emacs@HIDDEN; Sat, 29 Mar 2025 14:17:19 -0400
Received: from dancol.org ([2600:3c01:e000:3d8::1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dancol@HIDDEN>) id 1tyak9-0004yN-Eh
 for bug-gnu-emacs@HIDDEN; Sat, 29 Mar 2025 14:17:19 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; 
 s=x;
 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=qw5uxKJpMG5dgCGUMo0vkcaml42MvQJcUaEqv9mCmTM=; b=fQ/UUwa9uE5RgDKcwOUU+UYpuH
 Yq6HnVYD+Az1GwQMEsalC3JHLjANaiwhl8W1Fo5ZUyxwj6xzMUfvUQFlk4N0Hd8frCBY21f3Jawsc
 ip5ByjIuc8FzBR6Vva5RFhFqFAevRLTmk7RdwmbtrxjFXZpsZs/WBhZ37G0QeJ1EB2a4G2kro1B/C
 998QFEMAgldTjBWyL/7nV2pUW49eHvG6nnufylagh+Np8cQsJqoilH7JaEC9GF4MOoGYXFkm8yk9m
 3Y2GlAtu+LxrwD6/N+h1LOBMe3m6uJLLkhis0Id0xscjDM62iwwzIrX7WGbJdY2scOIZeNQ3zIKZe
 aY0mGzqg==;
Received: from dancol by dancol.org with local (Exim 4.96)
 (envelope-from <dancol@HIDDEN>) id 1tyaji-004RNQ-1v
 for bug-gnu-emacs@HIDDEN; Sat, 29 Mar 2025 14:16:50 -0400
From: Daniel Colascione <dancol@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: typescript-ts-mode's defun definition is wrong
User-Agent: mu4e 1.12.8; emacs 31.0.50
Date: Sat, 29 Mar 2025 14:17:15 -0400
Message-ID: <m1r02fd7mc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2600:3c01:e000:3d8::1;
 envelope-from=dancol@HIDDEN; helo=dancol.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://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: <https://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 (/)

Not sure whether this is a bug or just surprising design, but in this
code:

    function Blah(foo) {
      const foo = 1;
      const bar = 2;
    }

with point on "const foo", I do not expect end-of-defun to go to "const
bar".  I expect it to go to the closing curly brace.




Acknowledgement sent to Daniel Colascione <dancol@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#77369; 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: Thu, 3 Apr 2025 07:45:02 UTC

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