Skip to content

Scanner (?), broken escape sequence detection #24198

Description

@Bruno-Vdr

Describe the bug

It looks like there is a problem when parsing escaped single quote within string interpolation in the scanner (Spytheman's hypothesis).

Reproduction Steps

module main

import term

fn main() {
	println('Hey it\'s ${term.blue('Tony\'s')} car !')
}

Expected Behavior

Fine compilation.

Current Behavior

main.v:8:1: error: unfinished string literal
    6 |     println('Hey it\'s ${term.blue('Tony\'s')} car !')
    7 | }

Possible Solution

Using a local variable.

		str := 'Tony\'s'
		println('Hey it\'s ${term.blue(str)} car !')

Additional Information/Context

Spytheman also add (Note double quotes):
https://discord.com/channels/592103645835821068/592294828432424960/1360579781992644700

module main

import term

fn main() {
	println('Hey it\'s ${term.blue("Tony\'s")} car !')
}

also work, but vfmt tool will replace double quotes by single, and next compilation will fail.

V version

V 0.4.10 c2e27ef

Environment details (OS name and version, etc.)

Debian linux testing (trixie)

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions