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

Compiler mistakes index (should be number type) for text type in repeat loop #42

Closed
mikeogezi opened this issue Dec 14, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@mikeogezi
Copy link
Contributor

mikeogezi commented Dec 14, 2023

Describe the bug
When repeat looping based on a number that has been set in a variable, the compiler thinks that the index is a text variable.

To Reproduce

@l = list("a", "b", "c")
@s = 3
repeat i for s {
  @x = getListItem(l, i)
}
@l = list("a", "b", "c")
@s = count(l)
repeat i for s {
  @x = getListItem(l, i)
}

Debug output

Parsing test.cherri...

Invalid variable value i (text) for argument 'index' (number).
getListItem(..., number index)

----- test.cherri:14:1
13 |   @x = getListItem(l, i)
14 | }
    ^
15 | 
-----

###################
#   DEBUG PANIC   #
###################

### PARSING ###

Previous Character:
) 14:0

Current Character:
LF 14:0

Next Character:
} 14:0

Current Line:
}
## TOKENS ##
1 | {variable l action {list [{text a} {text b} {text c}]}}
2 | {variable s action {count [{variable l}]}}
3 | {repeat  EB4EF905-7402-43BA-8B7F-CC29563C57F1 variable s}
4 | {variable i variable Repeat Index}

## DEFINITIONS ##
Name: test
Color: -1263359489
Glyph: 61440
Inputs: []
Outputs: []
Workflows: []
No Input: { []}
macOS Only: false
Mininum Version: 2106.0.3
iOS Version: 17.0

## VARIABLES ##
@s = {count [{variable l}]} (action)
@i = i (text) (repeat item var)
@l = {list [{text a} {text b} {text c}]} (action)

## MENUS ##
map[]

## IMPORT QUESTIONS ##
map[]

### PLIST GEN ###

## UUIDS ##
map[]

### CUSTOM ACTIONS ###


### INCLUDES ###

## INCLUDED ##
[]

## INCLUDES MAP ##
[]

#############################################################

panic: debug

goroutine 1 [running]:
main.panicDebug({0x0, 0x0})
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/main.go:320 +0x12c
main.parserError({0x1400010a2a0, 0x5d})
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:1411 +0x2a0
main.typeCheck(0x14000153468, 0x14000153130?)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/action.go:323 +0x31c
main.checkArg(0x140001b5468, 0x140001b5378)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/action.go:401 +0xb8
main.collectArgument(0x0?, 0x14000153468, 0x140001285d0?)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:415 +0x2dc
main.collectArguments()
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:382 +0x12c
main.collectAction()
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:1187 +0x220
main.collectValue(0x140001537b0, 0x140001b57c0, 0xa)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:308 +0x4e4
main.collectVariableValue(0x0, 0x140001b57b0, 0x140001b57c0, 0x140001b57f0, 0x140001b57e0)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:242 +0x3c
main.collectVariable(0x0)
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:487 +0x6e8
main.parse()
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:147 +0x480
main.initParse()
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/parser.go:49 +0x2f4
main.main()
        /Users/michaelogezi/go/pkg/mod/github.com/electrikmilk/[email protected]/main.go:75 +0x35c

Expected behavior
I expect the index to be a number.

Version Information (please complete the following information):

  • macOS version (run uname -a): Darwin Michaels-MacBook-Air.local 23.2.0 Darwin Kernel Version 23.2.0: Fri Oct 13 09:28:08 PDT 2023; root:xnu-10002.60.54~14/RELEASE_ARM64_T8112 arm64
  • Golang version (run go version): go version go1.21.4 darwin/arm64

Additional Information:
May be related to #41.

@mikeogezi mikeogezi added the bug Something isn't working label Dec 14, 2023
@mikeogezi mikeogezi changed the title Compiler mistakes index (number type) for text type in repeat loop Compiler mistakes index (should be number type) for text type in repeat loop Dec 14, 2023
@mikeogezi
Copy link
Contributor Author

mikeogezi commented Dec 14, 2023

@electrikmilk, toward fixing this issue: #44. Let me know your thoughts.

@electrikmilk
Copy link
Owner

This just needed the value type corrected to 'Integer'. This is fixed by ad5f0b1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants