[ragel-users] "declared but not used" errors with v7 Go backend

Adrian Thurston thurston at colm.net
Fri Nov 2 08:28:43 UTC 2018


 

Still a problem in master. The unused arrays should be eliminated from
the code generation because they cause warnings in other languages as
well. But using _ is a nice workaround at present. 

Thanks! 

Adrian 

On 2018-11-01 10:12, Damian Gryski wrote: 

> This is with ragel 7.0.0.11 and colm 0.13.0.6. I was unable to get ragel to build from git. 
> 
> With the example grammar at github.com/dgryski/ragel-examples/regexp1 [2], I get the following error: 
> 
> $ ragel-go sshd.rl 
> $ go build 
> # github.com/dgryski/ragel-examples/regexp1 [2] 
> ./sshd.go:11:6: _scanner_trans_cond_spaces declared and not used 
> ./sshd.go:12:6: _scanner_trans_offsets declared and not used 
> ./sshd.go:13:6: _scanner_trans_lengths declared and not used 
> ./sshd.go:14:6: _scanner_cond_keys declared and not used 
> ./sshd.go:17:6: _scanner_eof_cond_spaces declared and not used 
> ./sshd.go:18:6: _scanner_eof_cond_key_offs declared and not used 
> ./sshd.go:19:6: _scanner_eof_cond_key_lens declared and not used 
> ./sshd.go:20:6: _scanner_eof_cond_keys declared and not used 
> ./sshd.go:21:6: _scanner_nfa_targs declared and not used 
> ./sshd.go:22:6: _scanner_nfa_offsets declared and not used 
> ./sshd.go:22:6: too many errors 
> 
> The usual solution to this in autogenerated code is to assign them to `_`, the underscore "blank variable". This satisfies the compiler and the entire array will be eliminated as a dead-store if it ends up not being used. 
> 
> Thus, each declaration for variables which may or may not be used will look like: 
> var _scanner_trans_cond_spaces [] int8 = [] int8 { ... } 
> _ = _scanner_trans_cond_space 
> 
> Note also the first `[] int8` is redundant -- the compiler will infer the type from the type of the array on the right hand side of the `=`. 
> 
> Fixing these issues in the Go template in the src/host-go directory and rebuilding fixed these errors (although I had to copy files from the git checkout for the template changes to recompile successfully). 
> 
> Damian 
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users [1]
 

Links:
------
[1] http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
[2] http://github.com/dgryski/ragel-examples/regexp1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20181102/3d01ee14/attachment.html>


More information about the ragel-users mailing list