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

[clarity] type-checker error with list of callable principals #4622

Open
obycode opened this issue Apr 2, 2024 · 1 comment
Open

[clarity] type-checker error with list of callable principals #4622

obycode opened this issue Apr 2, 2024 · 1 comment
Labels

Comments

@obycode
Copy link
Contributor

obycode commented Apr 2, 2024

Describe the bug
This Clarity code that appears valid gets an error from the type-checker:

(replace-at?
    (list
      'SK1655DMX0A8VKB0W7R2EN6B29MS98G1HTZV2XW41.CKPAbAeaxopNIumug
      'ST3Z7C6C0Q0VWBM06788X4P386517JNEAYTN1SRB7.euEUmoKftalFLQpCsmeswgNWQQcRelTgmVVSY
      'S12R7Q5M2WN8PYVPNH9RXHMHV1GDX1PCT9XQFZ1VF.zQurKADWgvZWXBvpAb
    )
    u1
    'SK1655DMX0A8VKB0W7R2EN6B29MS98G1HTZV2XW41.CKPAbAeaxopNIumug
)

Steps To Reproduce
Example unit test:

#[test]
fn test_replace_at_callable() {
    let contract = "(replace-at?
        (list
          'SK1655DMX0A8VKB0W7R2EN6B29MS98G1HTZV2XW41.CKPAbAeaxopNIumug
          'ST3Z7C6C0Q0VWBM06788X4P386517JNEAYTN1SRB7.euEUmoKftalFLQpCsmeswgNWQQcRelTgmVVSY
          'S12R7Q5M2WN8PYVPNH9RXHMHV1GDX1PCT9XQFZ1VF.zQurKADWgvZWXBvpAb
        )
        u1
        'SK1655DMX0A8VKB0W7R2EN6B29MS98G1HTZV2XW41.CKPAbAeaxopNIumug
      )";

    assert!(mem_type_check(contract).is_ok());
}

Expected behavior
This should be valid Clarity code.

@obycode obycode added the clarity label Apr 2, 2024
obycode added a commit that referenced this issue Apr 2, 2024
This is still a work in progress, as I am not sure yet if this is the
appropriate fix or if there is a call to `concretize` on the type
missing somewhere.

See: #4622
@csgui
Copy link

csgui commented Sep 13, 2024

Related to same issue. Checked with Clarinet.

>> ::set_epoch 2.0
Epoch updated to: 2.0
>> (index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
(some u0)
>> ::set_epoch 2.05
Epoch updated to: 2.05
>> (index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
(some u0)
>> ::set_epoch 2.1
Epoch updated to: 2.1
>> (index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
<stdin>:1:99: error: expecting expression of type '(principal S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)', found '(principal S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)'
(index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ::set_epoch 2.5
Epoch updated to: 2.5
>> (index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
<stdin>:1:99: error: expecting expression of type '(principal S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)', found '(principal S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)'
(index-of (list (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb)) (some 'S53AR76V04QBY9CKZFQZ6FZF0730CEQS2AH761HTX.FoUtMZdXvouVYyvtvceMcRGotjQlzb))
                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Status: 🆕 New
Development

No branches or pull requests

2 participants