"local FeatureVariable" differs from local Variable

This issue has been tracked since 2022-07-27.

The following may not be a bug, but I do not really see why the given variables differ in their scope.

The following code

<div _='
    set localVariable to `localVariable`
    set local FeatureVariable to `FeatureVariable`

    if (local FeatureVariable == :localVariable)
      put `"local FeatureVariable" is equivalent to "localVariable"` into #FeatureOutput
      put `"local FeatureVariable" differs from "localVariable"` into #FeatureOutput
<div id="FeatureOutput"></div>

shows that local variables created without any prefix differ from those created with a local prefix.

If they differ by purpose, this detail should be clearly explained in the docs.

A live example may be found here

dz4k wrote this answer on 2022-08-18

I don't get what the problem is here. You set two local variables to different values, and they are not equal. What was the expected behavior?

You are also trying to access :localVariable with a colon, which is undefined.

rozek wrote this answer on 2022-08-18

Indeed, the colon was wrong - but even without a colon, the problem persists: if local x and x would refer to the same variable, the comparison would yield true.

But currently, it is important to know how a local variable was created, whether with or without the local prefix

rozek wrote this answer on 2022-08-18

Damn...I found my mistake (must have been blind) Sorry for bothering you!

dz4k wrote this answer on 2022-08-18

Why would the comparison between localVariable and FeatureVariable be true?

This works as expected:

<script type=text/hyperscript>
    set x to 1
    set local x to 2
    put (x == local x) as String after me
dz4k wrote this answer on 2022-08-18

Oh, just saw you closed this

rozek wrote this answer on 2022-08-18

Yes, it's been my fault - sorry for wasting your time!

More Details About Repo
Owner Name bigskysoftware
Repo Name _hyperscript
Full Name bigskysoftware/_hyperscript
Language JavaScript
Created Date 2020-05-27
Updated Date 2022-11-25
Star Count 1265
Watcher Count 18
Fork Count 75
Issue Count 86


Issue Title Created Date Updated Date