Tcl Source Code

View Ticket
Login
Ticket UUID: 7e4d5a0a2b439cd36db77d3a5d6a09cb5c4f8d7c
Title: regexp behaviour differs based on passing option as literal v/s variable
Type: Bug Created on: 2016-05-20 13:10:13
Submitter: apnadkarni Assigned to: nobody
Subsystem: 47. Bytecode Compiler Severity: Minor
Priority: 5 Medium Last modified: 2026-10-11 07:39:52
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:
As seen below regexp behaviour is different based on -nocase (or any option) being passed as literal or through a variable.

% set switch -nocase
-nocase
% regexp $switch "Looking for -nocase"
1
% regexp -nocase "Looking for -nocase"
wrong # args: should be "regexp ?-option ...? exp string ?matchVar? ?subMatchVar ...?"

dgp from chat:

dgp	I'd guess a compiler bug
[18:36]	dgp	% set cmd regexp
		regexp
		% set switch -nocase
		-nocase
		% $cmd $switch "Looking for -nocase"
		wrong # args: should be "regexp ?-option ...? exp string ?matchVar? ?subMatchVar ...?"
User Comments:
serhiy.storchaka added on 2026-10-11 07:39:52:

Same cause as [1902890fff]. Proposed fix in branch regexp-compile-runtime-switch: compiled regexp $switch "Looking for -nocase" now gives "wrong # args", as the command does.