GithubHelp home page GithubHelp logo

Comments (3)

slushie avatar slushie commented on June 15, 2024

#104 addresses these unit test, but some have been commented out because they currently fail on master.

Those tests highlight a few missing features in the checker and parser.

Checker currently doesn't identify incorrect types used as, or inside of, option blocks. That is with wrongOptionType and with option { wrongOptionType; } both pass, but shouldn't. It seems this also affects usage like myfunc option::run { someCopyOpt; } where the option block is passed as a value.

In discussion with @hinshun we realized the need for CallSmts to be parsed as expressions, possibly as CallExpr. The parser and checker should also accept BlockStmts that contain BasicLits, so that string myDir { "/var/lib/foo"; } is a valid statement that assigns "/var/lib/foo" as the return value of myDir.

from hlb.

slushie avatar slushie commented on June 15, 2024
	// Option blocks may be empty and may refer to identifiers or function
	// literals that don't have a sub-type, so we check them differently.
	if strings.HasPrefix(string(typ), string(parser.Option)) {
		return c.checkOptionBlockStmt(scope, typ, block)
	}

in checker.checkBlockStmt seems to be the culprit for the checker issue.

@hinshun could you provide an example hlb program that has an option with a func literal that has no subtype? I'm not sure I know what that looks like and I want to write a test case for it so that I can try to fix the checker. NB if I comment out that block, most of the checks seem to work consistently.

from hlb.

hinshun avatar hinshun commented on June 15, 2024

@hinshun could you provide an example hlb program that has an option with a func literal that has no subtype? I'm not sure I know what that looks like and I want to write a test case for it so that I can try to fix the checker. NB if I comment out that block, most of the checks seem to work consistently.

I think what I meant by that comment is the following.

Option blocks may be empty.

fs default() {
    image "alpine"
    run "echo foo" with option {}
}

may refer to identifiers

fs default() {
    image "alpine"
    run "echo foo" with foo
}

option::run foo() {
    env "key" "value"
}

or function literals that don't have sub-type

fs default() {
    image "alpine"
    run "echo foo" with option { # <<- no sub-type.
        env "key" "value"
    }
}

When I wrote sub-type I was referring to (*parser.Type).Secondary(). The identifier after the primary type (in this case, option) followed by ::<sub-type>. We should probably reword this comment. Let me know if that clarifies things!

from hlb.

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.