From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Newsgroups: gmane.emacs.bugs Subject: bug#59816: 29.0.60; c++-ts-mode handles one-line comments badly Date: Sun, 4 Dec 2022 13:58:52 +0100 Message-ID: <08257d6b-2426-bbdf-0ed4-edd161801ad6@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37327"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 To: 59816@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 04 14:00:24 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1obX-0009Yw-00 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Dec 2022 14:00:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1obK-0004xr-60; Sun, 04 Dec 2022 08:00:12 -0500 Original-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 ) id 1p1obD-0004x6-AF for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 08:00:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1obC-00053c-NQ for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 08:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1obC-0007nZ-H4 for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 08:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Dec 2022 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59816 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167015874629936 (code B ref -1); Sun, 04 Dec 2022 13:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Dec 2022 12:59:06 +0000 Original-Received: from localhost ([127.0.0.1]:57551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oaH-0007mm-Cj for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:59:05 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:44376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oaC-0007mO-9v for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:59:03 -0500 Original-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 ) id 1p1oaC-0004rF-3Z for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 07:59:00 -0500 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1oa9-0004rG-El for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 07:58:59 -0500 Original-Received: by mail-ej1-x633.google.com with SMTP id vv4so21803998ejc.2 for ; Sun, 04 Dec 2022 04:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=B5f+QxFHThJsSNOe30NMgdixmIjXkMXsW0Ee6f7bfXA=; b=fKkddG/kemOxOcmXpOG5OsqB/hzOWTMh5CdIHiATIUIyrqt46Vv+dLgXZAHJEYaGyi D4c7+JtP3+lLZnJHmB14rsGxJeM+wRfDW89ANxj+/8s6EgHV9jCqhB+Y8FnHtxaEJDHU RkL3Pexc/DzJqq3IwbyaUiNb4WR6a+Gy73U2o0bplMObV4r8DN6fmhObHlK1AQ8jW+ZH zdi/sDcfVLGcMOgwP/OxngFMpvGYQjWyy/HsFkbV/YNbJjWnOqDaWXXX0k4qM0JseTkm YVi3wabyVx98W1OJ4vK0lXg3MEeQvw0Kg0+F4pz6OHG0LTT2IVD0iVNQrqG/6GSFxgOX Xufw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=B5f+QxFHThJsSNOe30NMgdixmIjXkMXsW0Ee6f7bfXA=; b=4aQS5fHDHsyS5/pnvPI8g/+BCjIdqh9uAFs1+2bbE2dnm7KOuXT3S4/+LpRnk4YnQN SbjtoZp+a44GWPliMonM2hqyN7KLITqLcrVUyOJorjJvAXlbY0wDQWdsy2yfq/ODr9cs DHZ2ekJWFc4vEx0likI9uMRo9Or1Ubk7txRkZtzCQ6E3kdMSDlcJStWW9j/qHiLhfvJ0 Bxxzq5OjJgNcBAmkjT/gYUQ2mXgljLnVE4rgfRWZNhZkJGelQcjs4Nt1M0Q6wgAWAsdA Mc9cIPbFEX0xpFAOOwtpWUozuI8G0w9LG/XUJJ846DdAT0760r4Cl0RepCnv2mvNKSh+ V48g== X-Gm-Message-State: ANoB5pn0XifkdiuxrKpcYIc07B+NBJE4/ZcjGMBwrFbrA5OQATReb2L3 u4gRb8ISHZyPXY47Q4MSP7F+ZecJ8EY= X-Google-Smtp-Source: AA0mqf6rWK1hiA0ks9HsqtJfDSgBEaYFQKZormE2O8G4coLDAbsB+6J2nQRIaVKe5OUjOOKG5vqUUw== X-Received: by 2002:a17:907:a78a:b0:7c0:ada7:f1b6 with SMTP id vx10-20020a170907a78a00b007c0ada7f1b6mr13281652ejc.173.1670158734706; Sun, 04 Dec 2022 04:58:54 -0800 (PST) Original-Received: from [192.168.8.4] (netacc-gpn-204-20-128.pool.yettel.hu. [5.204.20.128]) by smtp.gmail.com with ESMTPSA id w19-20020a17090649d300b007c0a7286c0asm4690098ejv.58.2022.12.04.04.58.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Dec 2022 04:58:54 -0800 (PST) Content-Language: sv-FI Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=geza.herman@gmail.com; helo=mail-ej1-x633.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249936 Archived-At: With the following simple program, emacs reports that "int a;" is in a comment: --------------------- void foo() {    // c    int a; } --------------------- Repro steps: - install tree-sitter-cpp available at https://github.com/tree-sitter/tree-sitter-cpp - copy the program above into a buffer - switch to c++-ts-mode - at the line "int a;", put the cursor at the 'i' (or anywhere in the line, exact position doesn't seem to matter) - M-: (nth 4 (syntax-ppss (point))) For me, this incorrectly returns "t". In c++-mode (without tree sitter), this correctly returns "nil". If I replace "// c" with "/* c */", the bug doesn't happen. It seems that one line comments don't end at the end of the line but last until the end of the buffer. The AST looks like this (with both comment styles there are the same) using treesit-explore-mode: (function_definition type: (primitive_type)  declarator:   (function_declarator declarator: (identifier)    parameters: (parameter_list ( )))  body:   (compound_statement { (comment)    (declaration type: (primitive_type) declarator: (identifier) ;)    })) Note I'm not sure whether this is an emacs, tree-sitter or tree-sitter-cpp bug. But because the AST is the same for /* */ kind of comment, and also if press RET on "(comment)" then only the "// c" comment is highlighted (so tree-sitter reports the correct area for the comment), I suppose that this is an emacs-related problem. In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version  3.24.20, cairo version 1.16.0) of 2022-12-04 built on zetor Repository revision: 84214578f5a2ff0d45312d9385442583f6877fb5 Repository branch: HEAD Windowing system distributor 'The X.Org Foundation', version 11.0.12008000 System Description: Debian GNU/Linux bullseye/sid Configured using:  'configure --with-native-compilation --without-compress-install  --with-xinput2 --with-xwidgets --with-tree-sitter  'CFLAGS=-fno-omit-frame-pointer -g3 -O2'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB Important settings:   value of $LC_ALL: C.UTF-8   value of $LANG: en_US.UTF-8   value of $XMODIFIERS: @im=none   locale-coding-system: utf-8-unix Major mode: C++//l Minor modes in effect:   tooltip-mode: t   global-eldoc-mode: t   show-paren-mode: t   electric-indent-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   line-number-mode: t   indent-tabs-mode: t   transient-mark-mode: t   auto-composition-mode: t   auto-encryption-mode: t   auto-compression-mode: t   abbrev-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs c-ts-mode treesit cl-loaddefs comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp byte-compile cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine 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 composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads xwidget-internal dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 108555 6531)  (symbols 48 9153 0)  (strings 32 26241 1411)  (string-bytes 1 905477)  (vectors 16 18498)  (vector-slots 8 368704 14814)  (floats 8 42 316)  (intervals 56 400 0)  (buffers 992 11))