Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:01:12+00:00 2026-06-03T14:01:12+00:00

I am trying to type assert from a []Node , to []Symbol . In

  • 0

I am trying to type assert from a []Node, to []Symbol. In my code, Symbol implements the Node interface.

Here is some surrounding code:

 43 func applyLambda(args []Node, env Env) Node {
 44     if len(args) > 2 {
 45         panic("invalid argument count")
 46     }
 47     fixed, rest := parseFormals(args.([]Symbol))
 48     return Func{
 49         Body: args[1],
 50         FixedVarNames: fixed,
 51         RestVarName: rest,
 52     }
 53 }

Here’s the error I get:

./builtins.go:47: invalid type assertion: args.([]Symbol) (non-interface type []Node on left)

I’m sure there’s a good reason for this. What’s the best way to proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:01:13+00:00Added an answer on June 3, 2026 at 2:01 pm

    In saying x.(T) variable x should be of interface type, because only for variables of type interface dynamic type is not fixed. And while Node is an interface, []Node is not. A slice is a distinct, non-interface type. So it just doesn’t make sense to assume a slice of interface values is an interface too.

    Type Node has a clear definition in your code and thus is an interface. You have specified the list of methods for it. Type []Node isn’t like that. What methods does it define?

    I understand where your are coming from with this. It may be a useful shortcut, but just doesn’t make sense. It’s kind of like expecting syms.Method() to work when syms‘s type is []Symbol and Method is for Symbol.

    Replacing line 47 with this code does what you want:

    symbols := make([]Symbol, len(args))
    for i, arg := range args { symbols[i] = arg.(Symbol) }
    fixed, rest := parseFormals(symbols)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do some basic proof of concept type code for a new
Trying to send a complex type between two systems that have the same code
I am a xml newbie trying to create a XDocument type from a xml
I am trying to use the tool XSD.EXE to generate some class files from
I am trying to understand type members in Scala. I wrote a simple example
I am trying to implement Type Hinting of PHP5 on one of my class,
I'm trying to understand type patterns and generic classes in Haskell but can't seem
Im trying set the single table inheritance model type in a form. So i
I am trying to update a field of type spFieldUserValue, you know a, PeoplePicker.
I am trying to assign a custom type as a key for std::map .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.