Giter Site home page Giter Site logo

Parser error, i think about assemblyscript HOT 8 OPEN

lortonx avatar lortonx commented on June 17, 2024
Parser error, i think

from assemblyscript.

Comments (8)

CountBleck avatar CountBleck commented on June 17, 2024

I'm not sure if AS supports typeof yet.

from assemblyscript.

HerrCai0907 avatar HerrCai0907 commented on June 17, 2024

I'm not sure if AS supports typeof yet.

yes. typeof will return a string of object type

from assemblyscript.

lortonx avatar lortonx commented on June 17, 2024

I'm not sure if AS supports typeof yet.

The problem is not even that, the problem is an error in the parser. Unfortunately, I didn’t check the typeof, but I saw that this have checks in tests https://github.com/AssemblyScript/assemblyscript/blob/main/tests/compiler/typeof.ts

from assemblyscript.

HerrCai0907 avatar HerrCai0907 commented on June 17, 2024

I have token a look about this issue. It is because parser handle alignof< typeof 1 > (); as Identifier LessThan Expression GreaterThan NotFinishedFunctionExpression.
It is hard to distinguish generic and lessThan and greaterThan operator without semantic analysis. But unfortunately, we will not do any semantic analysis in parser stage.

from assemblyscript.

CountBleck avatar CountBleck commented on June 17, 2024

typeof x when used as a type is parsed separately and differently from typeof x when used as an expression. For instance, typeof x(), typeof (x), typeof x[a ? b : c], and so on are parser errors in TS.

I suspect that typeof for types hasn't been implemented yet.

from assemblyscript.

CountBleck avatar CountBleck commented on June 17, 2024

The error you reported indicates the parser expected code like this, which is seen as (y < typeof x) > ((): i32 => 0), without the extra parentheses.

Edit: @HerrCai0907 beat me to it by 6 minutes and I didn't notice.

from assemblyscript.

HerrCai0907 avatar HerrCai0907 commented on June 17, 2024

Interesting thing is TS also have similar problem.
true<false>(true); is valid but let a=true;a<false>(true); is invalid.

from assemblyscript.

CountBleck avatar CountBleck commented on June 17, 2024

It is hard to distinguish generic and lessThan and greaterThan operator without semantic analysis.

Semantic analysis isn't necessary. TypeScript eagerly parses generics (which makes sense; practically no one would write a < typeof b, let alone a < typeof b > () => ... or a < typeof b > (c))

Interesting thing is TS also have similar problem.

You actually brought up what I typed above as I was typing it. 😆
Calling it a problem is a bit of an exaggeration, and true is probably treated specially as a keyword, thereby causing that case to be valid. It's not a major issue, since true < false > (true) is a generally useless expression.

from assemblyscript.

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.