aeternity / aesophia

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

Namespace overlap error is missing filename/location #378

Closed dincho closed 2 years ago

dincho commented 2 years ago

Compiling of the contract:

@compiler >= 6

include "BLS12_381.aes"

namespace BLS12_381 =
    type fp = int

main contract Bug =
    type number = int

leads to the following error

Type error in 'contracts/Bug.aes' at line 5, col 11:
The namespace BLS12_381 (at line 5, column 11) has the same name as a namespace at line 1, column 11

which reports wrong namespace location obviously

dincho commented 2 years ago

Perhaps the compiler annotation is not considered ? 🤔

dincho commented 2 years ago

Perhaps the compiler annotation is not considered ? 🤔

Nah, same error (location) with:

include "Set.aes"
include "BLS12_381.aes"

namespace BLS12_381 =
    type fp = int

main contract Bug =
    type number = int
hanssv commented 2 years ago

It is line 1, column 11 in BLS12_381.aes, right?

dincho commented 2 years ago

Sure, but then the file/where (BLS12_381.aes, ) is missing ?

dincho commented 2 years ago

For example the buildin namespace error makes much more sense:

Type error in 'contracts/Bug.aes' at line 5, col 11: The namespace MCL_BLS12_381 (at line 5, column 11) has the same name as a namespace at (builtin location)

So I'd expect:

The namespace BLS12_381 (at line 5, column 11) has the same name as a namespace at line 1, column 11 in BLS12_381.aes

dincho commented 2 years ago

Not very helpful with user defined namespaces as well:

➜  cat contracts/Bug.aes                   
@compiler >= 6

include "Bug2.aes"

namespace Busy =
    type bus = int

main contract Bug =
    type number = int

➜ cat contracts/Bug2.aes                  
@compiler >= 6

namespace Busy =
    type bus = int

➜ aesophia_cli contracts/Bug.aes          
Type error in 'contracts/Bug.aes' at line 5, col 11:
The namespace Busy (at line 5, column 11) has the same name as a namespace at line 3, column 11
hanssv commented 2 years ago

@ghallak is this something that could be improved?