alephium / alephium/docs

confused why compiler doesn't work

Open
#485 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
12
Forks
49
Avg merge
27m
Merged PRs (30d)
4

Description

my contract is this:

contract UserProfile {
let owner: Address
let mut username: ByteVec
let mut bio: ByteVec
let mut profilePicHash: ByteVec
let mut followers: [Address]

// Constructor function
pub fn initialize(ownerAddress: Address) -> () {
    owner = ownerAddress
    username = ByteVec::empty()
    bio = ByteVec::empty()
    profilePicHash = ByteVec::empty()
    followers = [] // Initialize empty followers array
}

// Verify caller is profile owner
fn checkOwner() -> () {
    assert!(callerAddress!() == owner, 0)
}

// Event Definitions
event ProfileUpdated(newBio: ByteVec, newPic: ByteVec)
event NewFollower(follower: Address)

// Update Profile function
pub fn updateProfile(newBio: ByteVec, newPic: ByteVec) -> () {
    checkOwner()
    bio = newBio
    profilePicHash = newPic
    emit ProfileUpdated(newBio, newPic)
}

// Follow function
pub fn follow() -> () {
    let follower = callerAddress!()
    if followers.exists(f => f == follower) {
        // Handle case where follower is already in the list
        emit NewFollower(follower)
    } else {
        followers.push(follower)
        emit NewFollower(follower)
    }
}

// Get Profile function
pub fn getProfile() -> (ByteVec, ByteVec, ByteVec, U256) {
    return (username, bio, profilePicHash, followers.length())
}

}

I get this error every time:

✘ Failed to compile, error: user_profile.ral (1:1): Syntax error
1 |contract UserProfile {
|^^^^^^^^^^

Expected end-of-input
Trace log: Expected multiContract:1:1 / end-of-input:10:1, found "contract U"
otoyume@otoyumes-MacBook-Pro alephi v_4 %

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported user_profile.ral input and the compiler trace at 1:1, then compare the contract syntax with the relevant documentation in this repository. Done means identifying whether the report requires a documentation correction or a compiler issue, with the expected behavior and reproduction clearly recorded.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.