Giter Club home page Giter Club logo

Comments (14)

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Btw, the error message I get is:

/Users/rjhala/research/liquid/RefScript/tests/pos/misc/init-00.ts:4:9-4:17: Error: TC-ERROR
Variable definition of 'i_SSA_0' with neither type annotation nor initialization is not supported.

from refscript.

panagosg7 avatar panagosg7 commented on September 28, 2024

Agreed. This has been around for a while, but now that we seem to have a clear story for 'undefined' we can just implicitly use that in cases where we don't have an initializer.

For the moment, writing down the 'undefined' should do it.

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

I see. Adding undefined doesn't quite cut it -- or rather it works for the one case, but not for the second second test I added, where TC complains about joining undefined and number. In general this is sketchy, because indeed, due to the while loop, maybe the i is indeed not defined but since the i is dead -- i.e. not used afterwards it shouldn't matter...

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Also, I thought I would hack around it by using the crash from the prelude to just make up a fictitious value of any-old type, but it get some strange error, see:

https://github.com/UCSD-PL/RefScript/blob/varinit/tests/pos/misc/init-02.ts

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

See the new tests I have added -- bottom-line is that the simple undefined
trick is not working. These seem like pretty simple things, and should be
fixed soon IMO.

On Mon, Sep 15, 2014 at 7:28 PM, Panagiotis Vekris <[email protected]

wrote:

Agreed. This has been around for a while, but now that we seem to have a
clear story for 'undefined' we can just implicitly use that in cases where
we don't have an initializer.

For the moment, writing down the 'undefined' should do it.

Reply to this email directly or view it on GitHub
#24 (comment).

Ranjit.

from refscript.

panagosg7 avatar panagosg7 commented on September 28, 2024

OK I made the fix that addresses:
https://github.com/UCSD-PL/RefScript/blob/varinit/tests/pos/misc/init-00.ts

This one:
https://github.com/UCSD-PL/RefScript/blob/varinit/tests/pos/misc/init-01.ts
will require some more thought - e.g. introduce a union at the exiting (from the loop) phi var.

The last one you posted:
https://github.com/UCSD-PL/RefScript/blob/varinit/tests/pos/misc/init-02.ts
is a TypeScript error. It has to do with the way TS sometimes treats open (polymorphic - as in forall A . A) types as {} -- the empty object type.

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

I suggest just merging (joining) T + undefined == undefined (keep it simple) ?

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Yikes. Is there any way around the TS error? crash or diverge is a pretty handy thing to have...
but anyway, if you fix the union issue -- by just special casing undefined -- thats fine too IMO, because
this is a common imperative idiom.

from refscript.

panagosg7 avatar panagosg7 commented on September 28, 2024

You can always 'any' it up.
I.e.

/*@ crash :: forall A . () => A */
declare function crash(): any;

from refscript.

panagosg7 avatar panagosg7 commented on September 28, 2024

OK I'll do the "simple - undefined" solution for the moment.

If we end up having situations like:

var i;
if (a > 0) i = a;
if (i) assert(i > 0);

we might have to revise

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Indeed -- good plan.

On Sep 15, 2014, at 8:15 PM, Panagiotis Vekris [email protected] wrote:

OK I'll do the "simple - undefined" solution for the moment.

If we end up having situations like:

var i;
if (a > 0) i = a;
if (i) assert(i > 0);
we might have to revise


Reply to this email directly or view it on GitHub.

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Btw wouldn't be explicit undefined plus number annotation on i work in this case?

On Sep 15, 2014, at 8:15 PM, Panagiotis Vekris [email protected] wrote:

OK I'll do the "simple - undefined" solution for the moment.

If we end up having situations like:

var i;
if (a > 0) i = a;
if (i) assert(i > 0);
we might have to revise


Reply to this email directly or view it on GitHub.

from refscript.

panagosg7 avatar panagosg7 commented on September 28, 2024

Yes, in this specific one the number annotation can be inferred.

But note that adding the annotation, means no SSA. So with multiple assignments you'd lose flow sensitivity.

from refscript.

ranjitjhala avatar ranjitjhala commented on September 28, 2024

Addressed by #26

(all tests pass.)

from refscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.