Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core\module] should show error in case magic methods are included #1623

Open
github-actions bot opened this issue Apr 29, 2024 · 0 comments
Open

[Core\module] should show error in case magic methods are included #1623

github-actions bot opened this issue Apr 29, 2024 · 0 comments
Labels
error handling Issues related to Error handling todo Automatically generated issues from TODOs in the code vm Issues related to the Virtual Machine implementation

Comments

@github-actions
Copy link

[Core\module] should show error in case magic methods are included
magic methods are of no use in that case

# TODO(Core\module) should show error in case magic methods are included


    builtin "module",
        alias       = unaliased,
        op          = opNop,
        rule        = PrefixPrecedence,
        description = "create new module with given contents",
        args        = {
            "contents"  : {Block, Dictionary}
        },
        attrs       = {
            "with"  : ({Block},"use given initialization parameters"),
        },
        returns     = {Module},
        # TODO(Core\module) add documentation example
        #  labels: library, documentation, easy
        example     = """
        """:
            #=======================================================
            var definitions: ValueDict = newOrderedTable[string,Value]()
            var inherits: Value = VNULL
            var super: ValueDict = newOrderedTable[string,Value]()
            var initUsing: ValueArray = @[]

            if checkAttr("with"):
                initUsing = aWith.a

            if xKind == Block:
                if (let constructorMethod = generatedConstructor(x.a); not constructorMethod.isNil):
                    definitions[$ConstructorM] = constructorMethod
                else:
                    for k,v in newDictionary(execDictionary(x)).d:
                        definitions[k] = v
            elif xKind == Dictionary:
                for k,v in x.d:
                    definitions[k] = copyValue(v)

            # TODO(Core\module) should show error in case magic methods are included
            #  magic methods are of no use in that case
            #  labels: vm, error handling
            
            # Get fields
            let fieldTable = getFieldTable(definitions)

            # Generate internal module identifier
            when not defined(WEB):
                let moduleId = "module" & "_" & $(genOid())
            else:
                let moduleId = "module" & "_" & $(rand(1_000_000_000..2_000_000_000))

            let proto = newPrototype(moduleId, definitions, inherits, fieldTable, super)
            let singleton = generateNewObject(proto, initUsing)

            push(newModule(singleton))

    builtin "new",
        alias       = unaliased, 
        op          = opNop,

6e3268d8c3f72a9a01e1529beba5e7af85adbae1

@github-actions github-actions bot added error handling Issues related to Error handling todo Automatically generated issues from TODOs in the code vm Issues related to the Virtual Machine implementation labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Issues related to Error handling todo Automatically generated issues from TODOs in the code vm Issues related to the Virtual Machine implementation
Projects
None yet
Development

No branches or pull requests

0 participants