aeternity / aesophia

Stand alone compiler for the Sophia smart contract language
https://docs.aeternity.com/aesophia
ISC License
52 stars 19 forks source link

Compiler Crashing #324

Closed nikita-fuchs closed 3 years ago

nikita-fuchs commented 3 years ago

Crashing on a saturday night:

contract Some_Other_Child_Contract =
    entrypoint sayHi() =
        "hello"

contract Identity = 
    record state = {
        name: string,
        surname: string,
        idNumber: int
        }

    entrypoint init(name: string, surname: string, idNumber: int) =
        { name = name,
          surname = surname,
          idNumber = idNumber
            }

    entrypoint getIdentity() =
        state

main contract IdentityService =

    stateful entrypoint createNewIdentity(name: string, surname: string, idNumber: int) =
        let identity = Chain.create(name, surname, idNumber) : Identity
        identity.address
nikita-fuchs commented 3 years ago

"Same" thing happening also with Chain.clone:

contract Some_Other_Child_Contract =
    entrypoint sayHi() =
        "hello"

contract Identity = 
    record state = {
        name: string,
        surname: string,
        idNumber: int
        }

    entrypoint init(name: string, surname: string, idNumber: int) =
        { name = name,
          surname = surname,
          idNumber = idNumber
            }

    entrypoint getIdentity() =
        state

main contract IdentityService =

    stateful entrypoint createNewIdentity(cloneFrom: Identity, name: string, surname: string, idNumber: int) =
        let identity = Chain.clone(ref=cloneFrom, name, surname, idNumber) : Identity
        identity.address
UlfNorell commented 3 years ago

The problem is that the state type from the child contract leaks into the parent contract. Work-around: add

type state = unit

to the main contract.