Comments (9)
Can you please provide a (possibly small) package that exhibits this problem?
I could not find readsig.go or SigElemType anywhere, and for me :env works with all packages that I tried until now...
Thanks
from gomacro.
yeah, sorry about that. It's difficult to minimize the reproducer.
type SigElemType int
is just a type in the code.
from gomacro.
I have an idea - it comes from the observation that :env only calls the String()
method (if available) of the constants, variables, functions and types declared in the package.
Maybe the package contains some SigElemType constants, and SigElemType has a method String()
that panics if the receiver is not one of the "known good" constants, and the SigElemType constant '9' is declared but is not among the "known good" ones?
Checking line 66 of readsig.go
, where the panic happens, could help verifying if this is the case...
from gomacro.
Yes, you were right, @cosmos72. I was missing some constants in a big switch doing String() string output. When I filled in the missing cases, then :env is happy.
Partial repro here:
https://github.com/glycerine/repro
from gomacro.
obviously this is user error on my part. My code should have had those constants. I'm sure rob pike published a tool at one point to generate those String() methods for us automagically, but I can't remember what it is called to find it again.
Anyway.
I'll leave this open--for you to close when you wish-- just in case something occurs to you that would make such confusion over cause less likely in the future. I'm not sure what to suggest other than to point out to me that the crash was in my code and not in gomacro; gomacro was invoking my code during :env
-- that's the part I didn't realize.
from gomacro.
Thanks :) it makes sense that a big switch could miss some cases.
I will harden :env against panics in String()
and GoString()
methods of the constants, variables, types and functions present in the package
from gomacro.
About autogenerating the String()
method:
if you do not find anything already implemented for the purpose, gomacro has extensive (although poorly documented) code generation features - it could be a nice and simple example, if I have time I will implement it and reply here
from gomacro.
Commit 6eee083 should fix this problem.
Anyway, as you wrote in https://github.com/glycerine/repro, a panic in the String()
method usually has a different and non-fatal effect: :env simply shows the panic message instead of the constant or variable, as for example:
ArrayFSMTy = %!v(PANIC=unknown SigElemType: '9') // repro.SigElemType
so, lacking a clear analysis, I am still not 100% convinced that commit 6eee083 is enough.
Can you try updating gomacro and re-running :env on your private package?
from gomacro.
Confirmed: the panics no longer crash gomacro. Looks good. Thanks again!
from gomacro.
Related Issues (20)
- Cannot convert slice to sliceHeader HOT 1
- can not import go rod HOT 4
- (REPL)How to import functions, how to interact with the code outside the string HOT 3
- I would like a full working example how to inject my application context(types and functions) in the REPL HOT 9
- Extract struct with methods from script to compiled code HOT 2
- Proxy can mix the called method of the imported structure HOT 3
- integrate with https://github.com/go-rod/rod HOT 2
- I'm unable to compile code importing gomacro on Mac OS m1 pro HOT 7
- Is there a way to Eval a folder HOT 5
- recursive type error cases: call of reflect.Value.Interface on zero Value HOT 6
- can't import fsm package HOT 4
- Different compilation behaviour from native go HOT 2
- undefined: pkgpath HOT 3
- Cannot convert struct to interface if it has an embedded struct with a method HOT 4
- Cannot import third party packages on Linux (not even the ones in the README) HOT 2
- Third-party imported type method is not callable from fast.Interp.Eval [gomacro repl works] HOT 4
- Idea for making adding third party packages to Gomacro easier when plugins aren't available HOT 3
- recursive type error cases: call of reflect.Value.Interface on zero Value
- can not import 3rd party packages HOT 13
- package <package> exports zero constants, functions, types, and variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomacro.