Skip to content

[Vapor] Incorrect merging of single prototype method called in various signatures #14244

@Hibi-10000

Description

@Hibi-10000

Vue version

3.6.0-beta.1

Link to minimal reproduction

https://play.vuejs.org/#eNrFU01v1DAQ/SuDhZSutElASBxCuhKgHuAAFXC0RJ1kduuS2JbthEVR/jtj76YEqV3tperJnnlvxm8+PLL3xmRDj6xgpautNB4c+t5AK9TukjPvOINBGG03XMmOTg/XVhsHW6s7SLI8WiFFwhVXtVbOg2zgEjgTVc0ZV2V+yEwZyPDYmVZ4JAugbOQQL3R9kabgbxFq4RD0Fkx8Jk1n/PBsIRuSJRuSlT8WSSI87v0RrXrvtdqMI8nKLNLjNV5wVnG2Dho5W8E0lfmRdlYQlfVf0EJl0KLt0ZDK9B78H4OhlUESg0KJLpiLvEmVrCERySrAg2j7gN+8HB+iTA1ub2Lx86NlfmhimS9ay9Y0OurDVu6yO6cVzXcMZNKuOyNbtF+NlzQszgqISMBE2+rfn6PP2x7Xs7++xfrXA/47tw8+zq4tOrQDUntmzAu7Qyo4wFffv8Ti78FON31L7BPgN3S67YPGA+1DrxqSveBFtZ/iTkq1++Gu9h6Vm4sKQgNzinzOaEM/nij9n9w32dsYx9VEXbxf77N+CA1HKowxZUwtmwKct6TvHeXbXKzoOP8/POMGLxxPusWnNvjngDbMk1pPQ8lepRV6kb1m019Y3IA3

Steps to reproduce

1. Open the link
2. There is an error
(3. Uncomment or comment out to check error)
(4. Remove vapor attribute in script tag to check no error)

What is expected?

No error

Functions should not be merged like:

const _id = $props.id
_setProp(n0, "name", _id.replace('b', 'a'))
_setValue(n0, `${_id.replace('b', 'a')}def`)

or same call signature in template literals, result is still merged like:

const __id_replace = $props.id.replace('b', 'a')
_setProp(n0, "name", __id_replace)
_setValue(n0, `${__id_replace}def`)

What is actually happening?

On Firefox, it throws error: String.prototype.replace called on incompatible undefined
On Chrome, it throws error: String.prototype.replace called on null or undefined or _id_replace is not a function

(followed by Cannot read properties of null (reading 'parent'))

Functions is wrongly merged like:

const _id_replace = $props.id.replace
_setProp(n0, "name", _id_replace('b', 'a'))
_setValue(n0, `${_id_replace('b', 'a')}def`)

System Info

Any additional comments?

Other String prototype methods are similar
Probably not specific to String prototype, more general

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: compilerscope: vaporrelated to vapor mode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions