You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Declaring a constant with a slice type should result in a compilation error, as slices are not valid constant types. However, the following code compiles and runs without error:
package main
funcmain() {
constb []string= []string{}
println("Hello", b)
}
Expected Behavior:
The code should not compile, and an error should be thrown indicating that slices cannot be used as constant types. This behavior is consistent with Go (Golang), where a similar code snippet results in an error stating invalid constant type []string.
Actual Behavior:
The code compiles and runs without any errors, printing "Hello" followed by the empty slice. This suggests that Gnolang does not enforce the expected type restrictions on constants.
The text was updated successfully, but these errors were encountered:
On Thu, 25 Jul 2024, at 01:15, 6h057 wrote:
Description:
*Issue Summary:*
eclaring a constant with a slice type should result in a compilation error, as slices are not valid constant types. However, the following code compiles and runs without error:
package main
func main() {
const b []string = []string{}
println("Hello", b)
}
*Expected Behavior:*
The code should not compile, and an error should be thrown indicating that slices cannot be used as constant types. This behavior is consistent with Go (Golang), where a similar code snippet results in an error stating `invalid constant type []string`.
*Actual Behavior:*
The code compiles and runs without any errors, printing "Hello" followed by the empty slice. This suggests that Gnolang does not enforce the expected type restrictions on constants.
—
Reply to this email directly, view it on GitHub <#2628>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABDW4XCZEZPMNE2HDPFKWO3ZOAYPRAVCNFSM6AAAAABLNNCYBSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZDQNRRG42TMNA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Description:
Issue Summary:
Declaring a constant with a slice type should result in a compilation error, as slices are not valid constant types. However, the following code compiles and runs without error:
Expected Behavior:
The code should not compile, and an error should be thrown indicating that slices cannot be used as constant types. This behavior is consistent with Go (Golang), where a similar code snippet results in an error stating
invalid constant type []string
.Actual Behavior:
The code compiles and runs without any errors, printing "Hello" followed by the empty slice. This suggests that Gnolang does not enforce the expected type restrictions on constants.
The text was updated successfully, but these errors were encountered: