diff --git a/vlib/v/gen/comptime.v b/vlib/v/gen/comptime.v index 933294110f..5a58845b1c 100644 --- a/vlib/v/gen/comptime.v +++ b/vlib/v/gen/comptime.v @@ -110,7 +110,7 @@ fn cgen_attrs(attrs []table.Attr) []string { fn (mut g Gen) comp_at(node ast.AtExpr) { if node.kind == .vmod_file { - val := cnewlines(node.val.replace('\r', '')).replace('\\', '\\\\') + val := cnewlines(node.val.replace('\r', '')) g.write('_SLIT("$val")') } else { val := node.val.replace('\\', '\\\\') diff --git a/vlib/v/tests/vmod_parser_test.v b/vlib/v/tests/vmod_parser_test.v index 20026370b3..c5c754afbe 100644 --- a/vlib/v/tests/vmod_parser_test.v +++ b/vlib/v/tests/vmod_parser_test.v @@ -3,9 +3,7 @@ import os fn test_from_file() { os.chdir(os.dir(os.getenv('VEXE'))) - data := vmod.from_file('./v.mod') or { - panic(err) - } + data := vmod.from_file('./v.mod') or { panic(err) } assert data.name == 'V' assert data.description == 'The V programming language.' assert data.version == '0.1.30' @@ -42,3 +40,10 @@ fn test_decode() { exit(0) } } + +fn test_decode_with_comptime_vmod_file() { + mod := vmod.decode(@VMOD_FILE) or { panic('Error decoding v.mod') } + assert mod.name == 'V' + assert mod.repo_url == 'https://github.com/vlang/v' + assert mod.license == 'MIT' +}