Skip to content

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 4, 2021

fix #4514

Copy link
Contributor

@lidlanca lidlanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider an additional test for the "local variable" in template, which is not explicitly
covered by the assignment fix test case

  test('template local variable', ()=>{
    const { content } = compile(
      `<script setup>
      import {ref} from "vue"
      const v = ref()
      </script>
      <template>
        <div @click="(e) => {
          let a = 1 
          const b = a
          var c = b
          (a,b,c,d,e)  // all local

          // nested scopes
          (()=>{
            let x = a
            (()=>{
              let z = x
              let z2 = z
            })
            let fromNonLocalZ = z // _ctx is expected
          })        
          v = a
          var d = 4
      }"/>

      </template>
      `,
      { inlineTemplate: true }
    )
    assertCode(content)
  })

@yyx990803 yyx990803 merged commit 5594643 into vuejs:master Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

template | local variable reference in a function is prefixed with _ctx
3 participants