ID:2051781
 
Not a bug
BYOND Version:510
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 48.0.2564.116
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
regex() is not considered a constant expression by the compiler. This is inconsistent with its behavior regarding similar procs such as list() or matrix().
Numbered Steps to Reproduce Problem:
Try to compile the code below:

Code Snippet (if applicable) to Reproduce Problem:
/datum/foo
var/regex/bar = regex("bar")


Expected Results:
The code will compile.
Actual Results:
test.dm:2:error: =: expected a constant expression

Does the problem occur:
Every time? Or how often?
Every time.
In other games?
n/a
In other user accounts?
n/a
On other computers?
n/a

When does the problem NOT occur?
Happens every time.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Occurs in earlier builds, AFAIK.

Workarounds:
/datum/foo
var/regex/bar = new /regex("bar")

Lummox JR resolved issue (Not a bug)
This is more of an enhancement issue.
This is inconsistent with its behavior regarding similar procs such as list() or matrix().

inconsistencies are technically still bugs
Not really; list() and matrix() are given special consideration for several good reasons. sound() is not given the same consideration, nor is icon().
Out of curiosity, what are the reasons list() and matrix() are treated differently that regex() doesn't have?
Sometimes list() is needed by a number of things, and it's convenient to be able to specify it at compile-time for those reasons. matrix() is used for transform, so that's necessary.

It occurs to me that new/regex() might actually work for your purposes; I believe new() with constants will simply be fed into an init proc, as lists are.