unexpected error

I’ve got a C header file (testfile.h) that only has a comment line "/* comment /". When I execute “puts” an error is generated:
1 | /
comment */
Error: invalid regex: quantifier does not follow a repeatable item at 0

Using Crystal 1.12.1 on x86_64-pc-windows-msvc

This is not expected behavior, shouldn’t it simply read the characters and return the string? If I wanted regex processing, I’d tell it to.

Any explanation or work around appreciated.

Just to be sure, you have a file testfile.h with

/* comment /

And another file, say, with


and you execute crystal and it fails?

Hmm, that case didn’t work earlier but now it does.

I’ve recreated the issue using an ARGV[0] input. The file is one line:


and is in the same directory as the testfile.h.

When executed using

crystal run testfile.h

it responds with the invalid regex error.

When you pass multiple paths to crystal run they are all treated as source files. So the compiler tries to read testfile.h as Crystal code (which it is not). If you want to pass options to the compiled program, you need to separate them with --: crystal run -- testfile.h

1 Like