# Language error: Forc compiling issues

**URL:** <https://forum.fuel.network/t/language-error-forc-compiling-issues/3900>\
**Category:** General\
**Created:** [December 26, 2023, 1:59am UTC](https://forum.fuel.network/t/language-error-forc-compiling-issues/3900 "2023-12-26T01:59:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayobamy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ayobamy/32/2012_2.png) [@ayobamy](https://forum.fuel.network/u/ayobamy)\
**Post date:** [December 26, 2023, 1:59am UTC](https://forum.fuel.network/t/language-error-forc-compiling-issues/3900/1 "2023-12-26T01:59:00Z")

</div>

Topic discussion checklist

- Hi guys. I seem to have issues with compiling when I use latest force version.

- Is there anyway I can solve this. The error messages are provided below.

- error  
 → /home/ahmed/fuel-project/counter-contract/src/main.sw:18:9  
|  
16 |  
17 | fn count() → u64 {  
18 | storage.counter  
| ^^^^^^^^^^^^^^^ Mismatched types.  
expected: u64  
found: StorageKey.  
help: Implicit return must match up with block’s type.  
19 | }  
|

* * *

error  
 → /home/ahmed/fuel-project/counter-contract/src/main.sw:18:9  
|  
16 |  
17 | fn count() → u64 {  
18 | storage.counter  
| ^^^^^^^^^^^^^^^ Mismatched types.  
expected: u64  
found: StorageKey.  
help: Function body’s return type does not match up with its return type annotation.  
19 | }  
|

* * *

error  
 → /home/ahmed/fuel-project/counter-contract/src/main.sw:23:9  
|  
21 |  
22 | fn increment() {  
23 | storage.counter = storage.counter + 1;  
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This expression is not valid on the left hand side of a reassignment.  
24 | }  
25 | }  
|

* * *

Aborting due to 3 errors.  
error: Failed to compile counter-contract

- Any other relevant information

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [December 26, 2023, 3:20am UTC](https://forum.fuel.network/t/language-error-forc-compiling-issues/3900/2 "2023-12-26T03:20:18Z")

</div>

Hey @ayobamy you cannot directly mutate or access storage variables like that. You have to use the `.write()` or `.read()` functions.

For example for your first two errors

```auto
#[storage(read)]
fn count() -> u64 {
    storage.counter.read()
}

```

for your last error

```auto
#[storage(read, write)]
fn increment() {
    let incremented = storage.counter.read() + 1;
    storage.counter.write(incremented);
}

```

Take another look at this section in the quickstart 🙂

> **[Building a Smart Contract | Fuel Docs](https://docs.fuel.network/guides/quickstart/building-a-smart-contract/#implement-abi)**
>
> Guides for the Fuel Network

---

<div class="post-metadata">

**Author:** ![ayobamy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ayobamy/32/2012_2.png) [@ayobamy](https://forum.fuel.network/u/ayobamy)\
**Post date:** [December 26, 2023, 8:52am UTC](https://forum.fuel.network/t/language-error-forc-compiling-issues/3900/3 "2023-12-26T08:52:07Z")

</div>

Alright, I will do that.

Thanks a lot for the prompt response.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [January 16, 2024, 4:53am UTC](https://forum.fuel.network/t/language-error-forc-compiling-issues/3900/4 "2024-01-16T04:53:04Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
