GithubHelp home page GithubHelp logo

Comments (5)

erkyrath avatar erkyrath commented on August 23, 2024

Expressions should be valid there. This is a code generation bug.

(In the line give obj 1 + 1, the expression gets folded to a constant at compile time. That's why the bug doesn't show up.)

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Whoops, hang on, I'm wrong about what happened.

The line give obj (1); is parsed as give X; where X is a function call obj(1). That's the ambiguity you were referring to. It's confusing because give X; is legal, according to the language def -- it gives the object X zero attributes.

Yeah, it's not obvious how to even detect this. We could warn on give X; but then the same problem occurs with give obj (1) light;.

Maybe the call syntax X(Y) can do some static type-checking.

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

On the other hand, the compiler should never produce an invalid file without complaining.

This is not a rule at all, I'm afraid. There are an infinite number of ways to produce an invalid story file. Calling X() where X is not a function is just one of them.

from inform6.

Natrium729 avatar Natrium729 commented on August 23, 2024

Ah, I didn't know it was possible to have a give statement without attributes. (And I also totally forgot about constant folding.)

In that case, yeah, the syntax is ambiguous but the compiler isn't wrong either, so I guess it's not a bug after all. (Although I would have thought interpreters would display an error message in the lines of "tried to call something that's not a routine".)

I suppose that, as you said, it should be possible to type-check routine calls, but that's not extremely important either.

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

#172 is the routine-call type check.

line 12: Warning:  In function call, expected Routine but found Object "obj"
>  give obj (1+1);

Of course this warning only appears when obj is an Object literal. If it's a local variable, the compiler can't help you.

from inform6.

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.